mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-13 16:06:21 +00:00
refactor: uploadController.js
some logic improvements
This commit is contained in:
parent
301cf3377d
commit
03eff45e8c
@ -440,13 +440,14 @@ self.actuallyUpload = async (req, res, user, data = {}) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (config.filterEmptyFile && file.size === 0) {
|
// file.size is not populated if a chunk upload, so ignore
|
||||||
|
if (config.filterEmptyFile && !file.isChunk && file.size === 0) {
|
||||||
throw new ClientError('Empty files are not allowed.')
|
throw new ClientError('Empty files are not allowed.')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
// Unlink temp files (do not wait)
|
// Unlink temp files (do not wait)
|
||||||
if (Array.isArray(req.files) && req.files.length) {
|
if (req.files.length) {
|
||||||
unlinkFiles(req.files)
|
unlinkFiles(req.files)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -637,9 +638,8 @@ self.actuallyUploadUrls = async (req, res, user, data = {}) => {
|
|||||||
// Unlink temp files (do not wait)
|
// Unlink temp files (do not wait)
|
||||||
if (filesData.length) {
|
if (filesData.length) {
|
||||||
Promise.all(filesData.map(async file => {
|
Promise.all(filesData.map(async file => {
|
||||||
if (file.filename) {
|
if (!file.filename) return
|
||||||
utils.unlinkFile(file.filename).catch(logger.error)
|
return utils.unlinkFile(file.filename).catch(logger.error)
|
||||||
}
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user