From 8b5a1faaa4724da596bfab371763dc632995c8ed Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 20 Jan 2022 02:33:20 +0900 Subject: [PATCH] refactor(server): use insert instead of save --- packages/backend/src/services/drive/add-file.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/services/drive/add-file.ts b/packages/backend/src/services/drive/add-file.ts index 38793412f..1153cf737 100644 --- a/packages/backend/src/services/drive/add-file.ts +++ b/packages/backend/src/services/drive/add-file.ts @@ -107,7 +107,7 @@ async function save(file: DriveFile, path: string, name: string, type: string, h file.size = size; file.storedInternal = false; - return await DriveFiles.save(file); + return await DriveFiles.insert(file).then(x => DriveFiles.findOneOrFail(x.identifiers[0])); } else { // use internal storage const accessKey = uuid(); const thumbnailAccessKey = 'thumbnail-' + uuid(); @@ -140,7 +140,7 @@ async function save(file: DriveFile, path: string, name: string, type: string, h file.md5 = hash; file.size = size; - return await DriveFiles.save(file); + return await DriveFiles.insert(file).then(x => DriveFiles.findOneOrFail(x.identifiers[0])); } } @@ -436,7 +436,7 @@ export default async function( file.type = info.type.mime; file.storedInternal = false; - file = await DriveFiles.save(file); + file = await DriveFiles.insert(file).then(x => DriveFiles.findOneOrFail(x.identifiers[0])); } catch (e) { // duplicate key error (when already registered) if (isDuplicateKeyValueError(e)) {