mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-24 20:03:08 +02:00
refactor(server): use insert instead of save
This commit is contained in:
parent
2a1d9a7428
commit
8b5a1faaa4
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.size = size;
|
||||||
file.storedInternal = false;
|
file.storedInternal = false;
|
||||||
|
|
||||||
return await DriveFiles.save(file);
|
return await DriveFiles.insert(file).then(x => DriveFiles.findOneOrFail(x.identifiers[0]));
|
||||||
} else { // use internal storage
|
} else { // use internal storage
|
||||||
const accessKey = uuid();
|
const accessKey = uuid();
|
||||||
const thumbnailAccessKey = 'thumbnail-' + 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.md5 = hash;
|
||||||
file.size = size;
|
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.type = info.type.mime;
|
||||||
file.storedInternal = false;
|
file.storedInternal = false;
|
||||||
|
|
||||||
file = await DriveFiles.save(file);
|
file = await DriveFiles.insert(file).then(x => DriveFiles.findOneOrFail(x.identifiers[0]));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// duplicate key error (when already registered)
|
// duplicate key error (when already registered)
|
||||||
if (isDuplicateKeyValueError(e)) {
|
if (isDuplicateKeyValueError(e)) {
|
||||||
|
|
Loading…
Reference in a new issue