mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-02 21:44:56 +02:00
clean up
This commit is contained in:
parent
9b79aab4d5
commit
3c9966e849
2 changed files with 25 additions and 14 deletions
|
@ -123,3 +123,20 @@ module.exports.zipDirectoriesPipe = (paths, filename, res) => {
|
|||
archive.finalize()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles errors that occur during the download process.
|
||||
*
|
||||
* @param error
|
||||
* @param res
|
||||
* @returns {*}
|
||||
*/
|
||||
module.exports.handleDownloadError = (error, res) => {
|
||||
if (!res.headersSent) {
|
||||
if (error.code === 'ENOENT') {
|
||||
return res.status(404).send('File not found')
|
||||
} else {
|
||||
return res.status(500).send('Download failed')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue