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) {
|
||||
refLog.logData.push({ color: "red", Message: "Backup Failed: Failed to get config" });
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ async function backup(refLog) {
|
||||
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 with errors" });
|
||||
Logging.updateLog(refLog.uuid, refLog.logData, taskstate.FAILED);
|
||||
await Logging.updateLog(refLog.uuid, refLog.logData, taskstate.FAILED);
|
||||
await pool.end();
|
||||
return;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ async function backup(refLog) {
|
||||
if (filteredTables.length === 0) {
|
||||
refLog.logData.push({ color: "red", Message: "Backup Failed: No tables to backup" });
|
||||
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();
|
||||
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`);
|
||||
refLog.logData.push({ color: "yellow", Message: "Begin Backup " + directoryPath });
|
||||
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 });
|
||||
Logging.updateLog(refLog.uuid, refLog.logData, taskstate.FAILED);
|
||||
await Logging.updateLog(refLog.uuid, refLog.logData, taskstate.FAILED);
|
||||
return;
|
||||
});
|
||||
const backup_data = [];
|
||||
@@ -152,7 +152,7 @@ async function backup(refLog) {
|
||||
} catch (error) {
|
||||
console.log(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();
|
||||
|
||||
@@ -27,10 +27,10 @@ async function runBackupTask(triggerType = triggertype.Automatic) {
|
||||
|
||||
console.log("Running Scheduled Backup");
|
||||
|
||||
Logging.insertLog(uuid, triggerType, taskName.backup);
|
||||
await Logging.insertLog(uuid, triggerType, taskName.backup);
|
||||
|
||||
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` });
|
||||
console.log("Scheduled Backup Complete");
|
||||
parentPort.postMessage({ status: "complete" });
|
||||
|
||||
Reference in New Issue
Block a user