mirror of
https://github.com/BreizhHardware/Jellystat.git
synced 2026-01-18 16:27:20 +01:00
Fix failed backup bug due to not awaiting log insert #393
This commit is contained in:
@@ -34,7 +34,7 @@ async function backup(refLog) {
|
|||||||
if (config.error) {
|
if (config.error) {
|
||||||
refLog.logData.push({ color: "red", Message: "Backup Failed: Failed to get config" });
|
refLog.logData.push({ color: "red", Message: "Backup Failed: Failed to get config" });
|
||||||
refLog.logData.push({ color: "red", Message: "Backup Failed with errors" });
|
refLog.logData.push({ color: "red", Message: "Backup Failed with errors" });
|
||||||
Logging.updateLog(refLog.uuid, refLog.logData, taskstate.FAILED);
|
await Logging.updateLog(refLog.uuid, refLog.logData, taskstate.FAILED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ async function backup(refLog) {
|
|||||||
console.error("No write permissions for the folder:", backuppath);
|
console.error("No write permissions for the folder:", backuppath);
|
||||||
refLog.logData.push({ color: "red", Message: "Backup Failed: No write permissions for the folder: " + backuppath });
|
refLog.logData.push({ color: "red", Message: "Backup Failed: No write permissions for the folder: " + backuppath });
|
||||||
refLog.logData.push({ color: "red", Message: "Backup Failed with errors" });
|
refLog.logData.push({ color: "red", Message: "Backup Failed with errors" });
|
||||||
Logging.updateLog(refLog.uuid, refLog.logData, taskstate.FAILED);
|
await Logging.updateLog(refLog.uuid, refLog.logData, taskstate.FAILED);
|
||||||
await pool.end();
|
await pool.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ async function backup(refLog) {
|
|||||||
if (filteredTables.length === 0) {
|
if (filteredTables.length === 0) {
|
||||||
refLog.logData.push({ color: "red", Message: "Backup Failed: No tables to backup" });
|
refLog.logData.push({ color: "red", Message: "Backup Failed: No tables to backup" });
|
||||||
refLog.logData.push({ color: "red", Message: "Backup Failed with errors" });
|
refLog.logData.push({ color: "red", Message: "Backup Failed with errors" });
|
||||||
Logging.updateLog(refLog.uuid, refLog.logData, taskstate.FAILED);
|
await Logging.updateLog(refLog.uuid, refLog.logData, taskstate.FAILED);
|
||||||
await pool.end();
|
await pool.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -82,9 +82,9 @@ async function backup(refLog) {
|
|||||||
const directoryPath = path.join(__dirname, "..", backupfolder, `backup_${now.format("yyyy-MM-DD HH-mm-ss")}.json`);
|
const directoryPath = path.join(__dirname, "..", backupfolder, `backup_${now.format("yyyy-MM-DD HH-mm-ss")}.json`);
|
||||||
refLog.logData.push({ color: "yellow", Message: "Begin Backup " + directoryPath });
|
refLog.logData.push({ color: "yellow", Message: "Begin Backup " + directoryPath });
|
||||||
const stream = fs.createWriteStream(directoryPath, { flags: "a" });
|
const stream = fs.createWriteStream(directoryPath, { flags: "a" });
|
||||||
stream.on("error", (error) => {
|
stream.on("error", async (error) => {
|
||||||
refLog.logData.push({ color: "red", Message: "Backup Failed: " + error });
|
refLog.logData.push({ color: "red", Message: "Backup Failed: " + error });
|
||||||
Logging.updateLog(refLog.uuid, refLog.logData, taskstate.FAILED);
|
await Logging.updateLog(refLog.uuid, refLog.logData, taskstate.FAILED);
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
const backup_data = [];
|
const backup_data = [];
|
||||||
@@ -152,7 +152,7 @@ async function backup(refLog) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
refLog.logData.push({ color: "red", Message: "Backup Failed: " + error });
|
refLog.logData.push({ color: "red", Message: "Backup Failed: " + error });
|
||||||
Logging.updateLog(refLog.uuid, refLog.logData, taskstate.FAILED);
|
await Logging.updateLog(refLog.uuid, refLog.logData, taskstate.FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
await pool.end();
|
await pool.end();
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ async function runBackupTask(triggerType = triggertype.Automatic) {
|
|||||||
|
|
||||||
console.log("Running Scheduled Backup");
|
console.log("Running Scheduled Backup");
|
||||||
|
|
||||||
Logging.insertLog(uuid, triggerType, taskName.backup);
|
await Logging.insertLog(uuid, triggerType, taskName.backup);
|
||||||
|
|
||||||
await backup(refLog);
|
await backup(refLog);
|
||||||
Logging.updateLog(uuid, refLog.logData, taskstate.SUCCESS);
|
await Logging.updateLog(uuid, refLog.logData, taskstate.SUCCESS);
|
||||||
sendUpdate("BackupTask", { type: "Success", message: `${triggerType} Backup Completed` });
|
sendUpdate("BackupTask", { type: "Success", message: `${triggerType} Backup Completed` });
|
||||||
console.log("Scheduled Backup Complete");
|
console.log("Scheduled Backup Complete");
|
||||||
parentPort.postMessage({ status: "complete" });
|
parentPort.postMessage({ status: "complete" });
|
||||||
|
|||||||
Reference in New Issue
Block a user