mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-30 18:48:55 +01:00
31 lines
930 B
JavaScript
31 lines
930 B
JavaScript
const Logger = require('../Logger')
|
|
|
|
class BackupController {
|
|
constructor() { }
|
|
|
|
async delete(req, res) {
|
|
if (!req.user.isRoot) {
|
|
Logger.error(`[BackupController] Non-Root user attempting to delete backup`, req.user)
|
|
return res.sendStatus(403)
|
|
}
|
|
var backup = this.backupManager.backups.find(b => b.id === req.params.id)
|
|
if (!backup) {
|
|
return res.sendStatus(404)
|
|
}
|
|
await this.backupManager.removeBackup(backup)
|
|
res.json(this.backupManager.backups.map(b => b.toJSON()))
|
|
}
|
|
|
|
async upload(req, res) {
|
|
if (!req.user.isRoot) {
|
|
Logger.error(`[BackupController] Non-Root user attempting to upload backup`, req.user)
|
|
return res.sendStatus(403)
|
|
}
|
|
if (!req.files.file) {
|
|
Logger.error('[BackupController] Upload backup invalid')
|
|
return res.sendStatus(500)
|
|
}
|
|
this.backupManager.uploadBackup(req, res)
|
|
}
|
|
}
|
|
module.exports = new BackupController() |