0
0

refactor(server): use insert instead of save

This commit is contained in:
syuilo 2022-01-20 02:33:20 +09:00
parent 2a1d9a7428
commit 8b5a1faaa4

View File

@ -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)) {