Refresh next backup date after backup

This commit is contained in:
SebClem 2024-11-26 14:24:44 +01:00
parent 3582753495
commit af7c90c839
Signed by: sebclem
GPG Key ID: 5A4308F6A359EA50
2 changed files with 5 additions and 2 deletions

View File

@ -36,7 +36,7 @@ export function initCron(backupConfig: BackupConfig) {
rej(Error(cronItem.id));
}
}
const nextDate = getNextDate(cronList);
const nextDate = getNextDate();
const status = getStatus();
status.next_backup = nextDate;
setStatus(status);
@ -44,7 +44,7 @@ export function initCron(backupConfig: BackupConfig) {
});
}
function getNextDate(cronList: Map<string, CronJob>) {
export function getNextDate() {
let nextDate: DateTime | undefined = undefined;
for (const item of cronList) {
const thisDate = item[1].nextDate();

View File

@ -15,6 +15,7 @@ import * as backupConfigService from "./backupConfigService.js";
import * as homeAssistantService from "./homeAssistantService.js";
import { getBackupFolder, getWebdavConfig } from "./webdavConfigService.js";
import * as webDavService from "./webdavService.js";
import { getNextDate } from "./cronService.js";
export function doBackupWorkflow(type: WorkflowType) {
let name = "";
@ -117,6 +118,7 @@ export function doBackupWorkflow(type: WorkflowType) {
status.last_backup.success = true;
status.last_backup.last_try = DateTime.now();
status.last_backup.last_success = DateTime.now();
status.next_backup = getNextDate();
statusTools.setStatus(status);
})
.catch(() => {
@ -216,6 +218,7 @@ function backupFail() {
const status = statusTools.getStatus();
status.last_backup.success = false;
status.last_backup.last_try = DateTime.now();
status.next_backup = getNextDate();
statusTools.setStatus(status);
messageManager.error("Last backup as failed !");
}