mirror of
https://github.com/Sebclem/hassio-nextcloud-backup.git
synced 2024-12-18 12:37:18 +01:00
Refresh next backup date after backup
This commit is contained in:
parent
3582753495
commit
af7c90c839
@ -36,7 +36,7 @@ export function initCron(backupConfig: BackupConfig) {
|
|||||||
rej(Error(cronItem.id));
|
rej(Error(cronItem.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const nextDate = getNextDate(cronList);
|
const nextDate = getNextDate();
|
||||||
const status = getStatus();
|
const status = getStatus();
|
||||||
status.next_backup = nextDate;
|
status.next_backup = nextDate;
|
||||||
setStatus(status);
|
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;
|
let nextDate: DateTime | undefined = undefined;
|
||||||
for (const item of cronList) {
|
for (const item of cronList) {
|
||||||
const thisDate = item[1].nextDate();
|
const thisDate = item[1].nextDate();
|
||||||
|
@ -15,6 +15,7 @@ import * as backupConfigService from "./backupConfigService.js";
|
|||||||
import * as homeAssistantService from "./homeAssistantService.js";
|
import * as homeAssistantService from "./homeAssistantService.js";
|
||||||
import { getBackupFolder, getWebdavConfig } from "./webdavConfigService.js";
|
import { getBackupFolder, getWebdavConfig } from "./webdavConfigService.js";
|
||||||
import * as webDavService from "./webdavService.js";
|
import * as webDavService from "./webdavService.js";
|
||||||
|
import { getNextDate } from "./cronService.js";
|
||||||
|
|
||||||
export function doBackupWorkflow(type: WorkflowType) {
|
export function doBackupWorkflow(type: WorkflowType) {
|
||||||
let name = "";
|
let name = "";
|
||||||
@ -117,6 +118,7 @@ export function doBackupWorkflow(type: WorkflowType) {
|
|||||||
status.last_backup.success = true;
|
status.last_backup.success = true;
|
||||||
status.last_backup.last_try = DateTime.now();
|
status.last_backup.last_try = DateTime.now();
|
||||||
status.last_backup.last_success = DateTime.now();
|
status.last_backup.last_success = DateTime.now();
|
||||||
|
status.next_backup = getNextDate();
|
||||||
statusTools.setStatus(status);
|
statusTools.setStatus(status);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@ -216,6 +218,7 @@ function backupFail() {
|
|||||||
const status = statusTools.getStatus();
|
const status = statusTools.getStatus();
|
||||||
status.last_backup.success = false;
|
status.last_backup.success = false;
|
||||||
status.last_backup.last_try = DateTime.now();
|
status.last_backup.last_try = DateTime.now();
|
||||||
|
status.next_backup = getNextDate();
|
||||||
statusTools.setStatus(status);
|
statusTools.setStatus(status);
|
||||||
messageManager.error("Last backup as failed !");
|
messageManager.error("Last backup as failed !");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user