mirror of
https://github.com/BreizhHardware/Jellystat.git
synced 2026-01-18 16:27:20 +01:00
update backup and readme
Handle file errors when dockerised
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user