mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-31 07:11:33 +00:00
Updated albumsController.js
Trying to purge empty albums (purge = also deleting all of the files associated with it) will no longer throw out warning about failing to delete any of the associated files (since there are supposed to be none for empty albums anyways).
This commit is contained in:
parent
4d7b23bb39
commit
ff3a6d1fb0
@ -138,7 +138,6 @@ albumsController.delete = async (req, res, next) => {
|
||||
return res.json({ success: false, description: 'No album specified.' })
|
||||
}
|
||||
|
||||
let ids = []
|
||||
let failed = []
|
||||
if (purge) {
|
||||
const files = await db.table('files')
|
||||
@ -147,11 +146,13 @@ albumsController.delete = async (req, res, next) => {
|
||||
userid: user.id
|
||||
})
|
||||
|
||||
ids = files.map(file => file.id)
|
||||
failed = await utils.bulkDeleteFiles('id', ids, user)
|
||||
if (files.length) {
|
||||
const ids = files.map(file => file.id)
|
||||
failed = await utils.bulkDeleteFiles('id', ids, user)
|
||||
|
||||
if (failed.length === ids.length) {
|
||||
return res.json({ success: false, description: 'Could not delete any of the files associated with the album.' })
|
||||
if (failed.length === ids.length) {
|
||||
return res.json({ success: false, description: 'Could not delete any of the files associated with the album.' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user