From 59520c31fde073f7cb0ede81162898f2bc340b4f Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 20 Jan 2022 02:43:13 +0900 Subject: [PATCH] refactor(server): use named export --- packages/backend/src/queue/processors/db/export-blocking.ts | 2 +- .../backend/src/queue/processors/db/export-custom-emojis.ts | 2 +- packages/backend/src/queue/processors/db/export-following.ts | 2 +- packages/backend/src/queue/processors/db/export-mute.ts | 2 +- packages/backend/src/queue/processors/db/export-notes.ts | 2 +- packages/backend/src/queue/processors/db/export-user-lists.ts | 2 +- .../backend/src/queue/processors/db/import-custom-emojis.ts | 2 +- .../backend/src/server/api/endpoints/drive/files/create.ts | 4 ++-- packages/backend/src/services/drive/add-file.ts | 2 +- packages/backend/src/services/drive/upload-from-url.ts | 4 ++-- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/backend/src/queue/processors/db/export-blocking.ts b/packages/backend/src/queue/processors/db/export-blocking.ts index 8c886d3b4..af5c7eba1 100644 --- a/packages/backend/src/queue/processors/db/export-blocking.ts +++ b/packages/backend/src/queue/processors/db/export-blocking.ts @@ -3,7 +3,7 @@ import * as tmp from 'tmp'; import * as fs from 'fs'; import { queueLogger } from '../../logger'; -import addFile from '@/services/drive/add-file'; +import { addFile } from '@/services/drive/add-file'; import * as dateFormat from 'dateformat'; import { getFullApAccount } from '@/misc/convert-host'; import { Users, Blockings } from '@/models/index'; diff --git a/packages/backend/src/queue/processors/db/export-custom-emojis.ts b/packages/backend/src/queue/processors/db/export-custom-emojis.ts index a420866dc..764356385 100644 --- a/packages/backend/src/queue/processors/db/export-custom-emojis.ts +++ b/packages/backend/src/queue/processors/db/export-custom-emojis.ts @@ -6,7 +6,7 @@ import { ulid } from 'ulid'; const mime = require('mime-types'); const archiver = require('archiver'); import { queueLogger } from '../../logger'; -import addFile from '@/services/drive/add-file'; +import { addFile } from '@/services/drive/add-file'; import * as dateFormat from 'dateformat'; import { Users, Emojis } from '@/models/index'; import { } from '@/queue/types'; diff --git a/packages/backend/src/queue/processors/db/export-following.ts b/packages/backend/src/queue/processors/db/export-following.ts index fbb9e2524..0c088dc37 100644 --- a/packages/backend/src/queue/processors/db/export-following.ts +++ b/packages/backend/src/queue/processors/db/export-following.ts @@ -3,7 +3,7 @@ import * as tmp from 'tmp'; import * as fs from 'fs'; import { queueLogger } from '../../logger'; -import addFile from '@/services/drive/add-file'; +import { addFile } from '@/services/drive/add-file'; import * as dateFormat from 'dateformat'; import { getFullApAccount } from '@/misc/convert-host'; import { Users, Followings, Mutings } from '@/models/index'; diff --git a/packages/backend/src/queue/processors/db/export-mute.ts b/packages/backend/src/queue/processors/db/export-mute.ts index 0b1fd24fe..f5928b875 100644 --- a/packages/backend/src/queue/processors/db/export-mute.ts +++ b/packages/backend/src/queue/processors/db/export-mute.ts @@ -3,7 +3,7 @@ import * as tmp from 'tmp'; import * as fs from 'fs'; import { queueLogger } from '../../logger'; -import addFile from '@/services/drive/add-file'; +import { addFile } from '@/services/drive/add-file'; import * as dateFormat from 'dateformat'; import { getFullApAccount } from '@/misc/convert-host'; import { Users, Mutings } from '@/models/index'; diff --git a/packages/backend/src/queue/processors/db/export-notes.ts b/packages/backend/src/queue/processors/db/export-notes.ts index e64e76351..df7675dec 100644 --- a/packages/backend/src/queue/processors/db/export-notes.ts +++ b/packages/backend/src/queue/processors/db/export-notes.ts @@ -3,7 +3,7 @@ import * as tmp from 'tmp'; import * as fs from 'fs'; import { queueLogger } from '../../logger'; -import addFile from '@/services/drive/add-file'; +import { addFile } from '@/services/drive/add-file'; import * as dateFormat from 'dateformat'; import { Users, Notes, Polls } from '@/models/index'; import { MoreThan } from 'typeorm'; diff --git a/packages/backend/src/queue/processors/db/export-user-lists.ts b/packages/backend/src/queue/processors/db/export-user-lists.ts index 44a8f9f67..b9b6cb0de 100644 --- a/packages/backend/src/queue/processors/db/export-user-lists.ts +++ b/packages/backend/src/queue/processors/db/export-user-lists.ts @@ -3,7 +3,7 @@ import * as tmp from 'tmp'; import * as fs from 'fs'; import { queueLogger } from '../../logger'; -import addFile from '@/services/drive/add-file'; +import { addFile } from '@/services/drive/add-file'; import * as dateFormat from 'dateformat'; import { getFullApAccount } from '@/misc/convert-host'; import { Users, UserLists, UserListJoinings } from '@/models/index'; diff --git a/packages/backend/src/queue/processors/db/import-custom-emojis.ts b/packages/backend/src/queue/processors/db/import-custom-emojis.ts index eb386bbb4..ba4e3f0c0 100644 --- a/packages/backend/src/queue/processors/db/import-custom-emojis.ts +++ b/packages/backend/src/queue/processors/db/import-custom-emojis.ts @@ -8,7 +8,7 @@ import { queueLogger } from '../../logger'; import { downloadUrl } from '@/misc/download-url'; import { DriveFiles, Emojis } from '@/models/index'; 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'; const logger = queueLogger.createSubLogger('import-custom-emojis'); diff --git a/packages/backend/src/server/api/endpoints/drive/files/create.ts b/packages/backend/src/server/api/endpoints/drive/files/create.ts index f598f18ed..379918154 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/create.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/create.ts @@ -1,7 +1,7 @@ import ms from 'ms'; import $ from 'cafy'; 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 { apiLogger } from '../../../logger'; import { ApiError } from '../../../error'; @@ -79,7 +79,7 @@ export default define(meta, async (ps, user, _, file, cleanup) => { try { // 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 }); } catch (e) { apiLogger.error(e); diff --git a/packages/backend/src/services/drive/add-file.ts b/packages/backend/src/services/drive/add-file.ts index 6ac4f6d11..9de4465eb 100644 --- a/packages/backend/src/services/drive/add-file.ts +++ b/packages/backend/src/services/drive/add-file.ts @@ -312,7 +312,7 @@ async function deleteOldFile(user: IRemoteUser) { * @param sensitive Mark file as sensitive * @return Created drive file */ -export default async function( +export async function addFile( user: { id: User['id']; host: User['host'] } | null, path: string, name: string | null = null, diff --git a/packages/backend/src/services/drive/upload-from-url.ts b/packages/backend/src/services/drive/upload-from-url.ts index 28f42bc34..a723c3e9a 100644 --- a/packages/backend/src/services/drive/upload-from-url.ts +++ b/packages/backend/src/services/drive/upload-from-url.ts @@ -1,5 +1,5 @@ import { URL } from 'url'; -import create from './add-file'; +import { addFile } from './add-file'; import { User } from '@/models/entities/user'; import { driveLogger } from './logger'; import { createTemp } from '@/misc/create-temp'; @@ -41,7 +41,7 @@ export default async ( let error; 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}`); } catch (e) { error = e;