update backup and readme

Handle file errors when dockerised
This commit is contained in:
Thegan Govender
2023-04-24 19:22:17 +02:00
parent ff4bbe58cf
commit 2c487a7189
2 changed files with 25 additions and 12 deletions

View File

@@ -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

View File

@@ -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.');
}
});