diff options
| author | Pitu <[email protected]> | 2021-01-07 03:08:00 +0900 |
|---|---|---|
| committer | Pitu <[email protected]> | 2021-01-07 03:08:00 +0900 |
| commit | df4e4272f4bd54ba9661d39a25b818f3fd1c9ec9 (patch) | |
| tree | c456fee579eb5f27af2a50a12630f8507ca3d49c /src/api | |
| parent | chore: bump version (diff) | |
| download | host.fuwn.me-df4e4272f4bd54ba9661d39a25b818f3fd1c9ec9.tar.xz host.fuwn.me-df4e4272f4bd54ba9661d39a25b818f3fd1c9ec9.zip | |
fix: early return if duplicated file
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/routes/uploads/uploadPOST.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/api/routes/uploads/uploadPOST.js b/src/api/routes/uploads/uploadPOST.js index 286a091..6d81221 100644 --- a/src/api/routes/uploads/uploadPOST.js +++ b/src/api/routes/uploads/uploadPOST.js @@ -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({ |