diff --git a/README.md b/README.md index eb89f54..bfd1785 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,12 @@ ## Current Features -- Session Monitoring anf logging +- Session Monitoring and logging - Statistics for all Libraries and Users - Watch History - User Overview and activity - Watch statisitcs +- Backup and restore Data ## Required Development - Responsive UI @@ -16,7 +17,7 @@ - Security Testing - More Validations and Error Handling - Auto sync library items -- Stats for Library Items (Eg Movies etc) +- Jellyfin Statistics Plugin Integration - More to come ## Getting Started diff --git a/backend/backup.js b/backend/backup.js index 3d3d50e..e839516 100644 --- a/backend/backup.js +++ b/backend/backup.js @@ -37,6 +37,11 @@ async function backup() { let now = moment(); const backupPath = `./backup-data/backup_${now.format('yyyy-MM-DD HH-mm-ss')}.json`; const stream = fs.createWriteStream(backupPath, { flags: 'a' }); + stream.on('error', (error) => { + console.error(error); + wss.sendMessageToClients({ color: "red", Message: "Backup Failed: "+error }); + throw new Error(error); + }); const backup_data=[]; wss.clearMessages(); @@ -212,16 +217,23 @@ router.get('/restore/:filename', async (req, res) => { router.delete('/files/:filename', (req, res) => { const filePath = path.join(__dirname, backupfolder, req.params.filename); - fs.unlink(filePath, (err) => { - if (err) { - console.error(err); - res.status(500).send('An error occurred while deleting the file.'); - return; - } - - console.log(`${filePath} has been deleted.`); - res.status(200).send(`${filePath} has been deleted.`); - }); + try{ + fs.unlink(filePath, (err) => { + if (err) { + console.error(err); + res.status(500).send('An error occurred while deleting the file.'); + return; + } + + console.log(`${filePath} has been deleted.`); + res.status(200).send(`${filePath} has been deleted.`); + }); + + }catch(error) + { + res.status(500).send('An error occurred while deleting the file.'); + } + });