Check if file exist before deleting it

This commit is contained in:
SebClem 2024-09-04 12:00:56 +02:00
parent 874eec7877
commit 3c6dcd9163
Signed by: sebclem
GPG Key ID: 5A4308F6A359EA50

View File

@ -1,4 +1,4 @@
import { unlinkSync } from "fs";
import { existsSync, unlinkSync } from "fs";
import { DateTime } from "luxon";
import logger from "../config/winston.js";
import messageManager from "../tools/messageManager.js";
@ -112,9 +112,10 @@ export function doBackupWorkflow(type: WorkflowType) {
})
.catch(() => {
backupFail();
if (tmpBackupFile != "") {
if (tmpBackupFile != "" && existsSync(tmpBackupFile)) {
unlinkSync(tmpBackupFile);
}
homeAssistantService.startAddons(addonsToStartStop).catch(() => {});
});
}