feat: delete zip of empty albums on download req

This commit is contained in:
Bobby 2022-10-04 05:16:51 +07:00
parent d5b1ad69d9
commit 34c060ec5e
No known key found for this signature in database
GPG Key ID: 941839794CBF5A09

View File

@ -607,6 +607,8 @@ self.generateZip = async (req, res) => {
.where('albumid', album.id)
if (files.length === 0) {
logger.log(`Finished zip task for album: ${identifier} (no files).`)
// Remove album ZIP if it exists
await jetpack.removeAsync(path.join(paths.zips, `${identifier}.zip`))
const clientErr = new ClientError('There are no files in the album.', { statusCode: 200 })
self.zipEmitters.get(identifier).emit('done', null, null, clientErr)
throw clientErr