Skip to content
Snippets Groups Projects
Commit 8b5a1faa authored by syuilo's avatar syuilo
Browse files

refactor(server): use insert instead of save

parent 2a1d9a74
No related branches found
No related tags found
No related merge requests found
......@@ -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)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment