fix: early return if duplicated file

This commit is contained in:
Pitu 2021-01-07 03:08:00 +09:00
parent ac5b3f29fa
commit df4e4272f4
1 changed files with 3 additions and 1 deletions

View File

@ -272,9 +272,11 @@ class uploadPOST extends Route {
if (!file) return;
}
// If nothing is returned means the file was duplicated and we already sent the response
const result = await Util.storeFileToDb(req, res, user, file, db);
if (albumId) await Util.saveFileToAlbum(db, albumId, result.id);
if (!result) return;
if (albumId) await Util.saveFileToAlbum(db, albumId, result.id);
result.deleteUrl = `${process.env.DOMAIN}/api/file/${result.id[0]}`;
return res.status(201).send({