refactor(server): use named export

This commit is contained in:
syuilo 2022-01-20 02:43:13 +09:00
parent 53937e09a0
commit 59520c31fd
10 changed files with 12 additions and 12 deletions

View File

@ -3,7 +3,7 @@ import * as tmp from 'tmp';
import * as fs from 'fs'; import * as fs from 'fs';
import { queueLogger } from '../../logger'; import { queueLogger } from '../../logger';
import addFile from '@/services/drive/add-file'; import { addFile } from '@/services/drive/add-file';
import * as dateFormat from 'dateformat'; import * as dateFormat from 'dateformat';
import { getFullApAccount } from '@/misc/convert-host'; import { getFullApAccount } from '@/misc/convert-host';
import { Users, Blockings } from '@/models/index'; import { Users, Blockings } from '@/models/index';

View File

@ -6,7 +6,7 @@ import { ulid } from 'ulid';
const mime = require('mime-types'); const mime = require('mime-types');
const archiver = require('archiver'); const archiver = require('archiver');
import { queueLogger } from '../../logger'; import { queueLogger } from '../../logger';
import addFile from '@/services/drive/add-file'; import { addFile } from '@/services/drive/add-file';
import * as dateFormat from 'dateformat'; import * as dateFormat from 'dateformat';
import { Users, Emojis } from '@/models/index'; import { Users, Emojis } from '@/models/index';
import { } from '@/queue/types'; import { } from '@/queue/types';

View File

@ -3,7 +3,7 @@ import * as tmp from 'tmp';
import * as fs from 'fs'; import * as fs from 'fs';
import { queueLogger } from '../../logger'; import { queueLogger } from '../../logger';
import addFile from '@/services/drive/add-file'; import { addFile } from '@/services/drive/add-file';
import * as dateFormat from 'dateformat'; import * as dateFormat from 'dateformat';
import { getFullApAccount } from '@/misc/convert-host'; import { getFullApAccount } from '@/misc/convert-host';
import { Users, Followings, Mutings } from '@/models/index'; import { Users, Followings, Mutings } from '@/models/index';

View File

@ -3,7 +3,7 @@ import * as tmp from 'tmp';
import * as fs from 'fs'; import * as fs from 'fs';
import { queueLogger } from '../../logger'; import { queueLogger } from '../../logger';
import addFile from '@/services/drive/add-file'; import { addFile } from '@/services/drive/add-file';
import * as dateFormat from 'dateformat'; import * as dateFormat from 'dateformat';
import { getFullApAccount } from '@/misc/convert-host'; import { getFullApAccount } from '@/misc/convert-host';
import { Users, Mutings } from '@/models/index'; import { Users, Mutings } from '@/models/index';

View File

@ -3,7 +3,7 @@ import * as tmp from 'tmp';
import * as fs from 'fs'; import * as fs from 'fs';
import { queueLogger } from '../../logger'; import { queueLogger } from '../../logger';
import addFile from '@/services/drive/add-file'; import { addFile } from '@/services/drive/add-file';
import * as dateFormat from 'dateformat'; import * as dateFormat from 'dateformat';
import { Users, Notes, Polls } from '@/models/index'; import { Users, Notes, Polls } from '@/models/index';
import { MoreThan } from 'typeorm'; import { MoreThan } from 'typeorm';

View File

@ -3,7 +3,7 @@ import * as tmp from 'tmp';
import * as fs from 'fs'; import * as fs from 'fs';
import { queueLogger } from '../../logger'; import { queueLogger } from '../../logger';
import addFile from '@/services/drive/add-file'; import { addFile } from '@/services/drive/add-file';
import * as dateFormat from 'dateformat'; import * as dateFormat from 'dateformat';
import { getFullApAccount } from '@/misc/convert-host'; import { getFullApAccount } from '@/misc/convert-host';
import { Users, UserLists, UserListJoinings } from '@/models/index'; import { Users, UserLists, UserListJoinings } from '@/models/index';

View File

@ -8,7 +8,7 @@ import { queueLogger } from '../../logger';
import { downloadUrl } from '@/misc/download-url'; import { downloadUrl } from '@/misc/download-url';
import { DriveFiles, Emojis } from '@/models/index'; import { DriveFiles, Emojis } from '@/models/index';
import { DbUserImportJobData } from '@/queue/types'; import { DbUserImportJobData } from '@/queue/types';
import addFile from '@/services/drive/add-file'; import { addFile } from '@/services/drive/add-file';
import { genId } from '@/misc/gen-id'; import { genId } from '@/misc/gen-id';
const logger = queueLogger.createSubLogger('import-custom-emojis'); const logger = queueLogger.createSubLogger('import-custom-emojis');

View File

@ -1,7 +1,7 @@
import ms from 'ms'; import ms from 'ms';
import $ from 'cafy'; import $ from 'cafy';
import { ID } from '@/misc/cafy-id'; import { ID } from '@/misc/cafy-id';
import create from '@/services/drive/add-file'; import { addFile } from '@/services/drive/add-file';
import define from '../../../define'; import define from '../../../define';
import { apiLogger } from '../../../logger'; import { apiLogger } from '../../../logger';
import { ApiError } from '../../../error'; import { ApiError } from '../../../error';
@ -79,7 +79,7 @@ export default define(meta, async (ps, user, _, file, cleanup) => {
try { try {
// Create file // Create file
const driveFile = await create(user, file.path, name, null, ps.folderId, ps.force, false, null, null, ps.isSensitive); const driveFile = await addFile(user, file.path, name, null, ps.folderId, ps.force, false, null, null, ps.isSensitive);
return await DriveFiles.pack(driveFile, { self: true }); return await DriveFiles.pack(driveFile, { self: true });
} catch (e) { } catch (e) {
apiLogger.error(e); apiLogger.error(e);

View File

@ -312,7 +312,7 @@ async function deleteOldFile(user: IRemoteUser) {
* @param sensitive Mark file as sensitive * @param sensitive Mark file as sensitive
* @return Created drive file * @return Created drive file
*/ */
export default async function( export async function addFile(
user: { id: User['id']; host: User['host'] } | null, user: { id: User['id']; host: User['host'] } | null,
path: string, path: string,
name: string | null = null, name: string | null = null,

View File

@ -1,5 +1,5 @@
import { URL } from 'url'; import { URL } from 'url';
import create from './add-file'; import { addFile } from './add-file';
import { User } from '@/models/entities/user'; import { User } from '@/models/entities/user';
import { driveLogger } from './logger'; import { driveLogger } from './logger';
import { createTemp } from '@/misc/create-temp'; import { createTemp } from '@/misc/create-temp';
@ -41,7 +41,7 @@ export default async (
let error; let error;
try { try {
driveFile = await create(user, path, name, comment, folderId, force, link, url, uri, sensitive); driveFile = await addFile(user, path, name, comment, folderId, force, link, url, uri, sensitive);
logger.succ(`Got: ${driveFile.id}`); logger.succ(`Got: ${driveFile.id}`);
} catch (e) { } catch (e) {
error = e; error = e;