mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-14 14:07:38 -07:00
refactor(server): use insert instead of save
This commit is contained in:
parent
934132e08a
commit
6c01a2aec1
1 changed files with 3 additions and 3 deletions
|
@ -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)) {
|
||||
|
|
Loading…
Reference in a new issue