backups: add stop_integrity_check route
This commit is contained in:
@@ -101,9 +101,9 @@ function createActionMenu(backup) {
|
||||
separator: true,
|
||||
}, {
|
||||
icon: 'fa-solid fa-key',
|
||||
label: t('backups.checkIntegrity'),
|
||||
label: backup.integrityCheckTaskId ? t('backups.stopIntegrity') : t('backups.checkIntegrity'),
|
||||
visible: props.app.accessLevel === 'admin',
|
||||
action: onCheckIntegrity.bind(null, backup),
|
||||
action: backup.integrityCheckTaskId ? onStopIntegrityCheck.bind(null, backup) : onStartIntegrityCheck.bind(null, backup),
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -248,7 +248,10 @@ async function refreshIntegrityTasks() {
|
||||
const [error, result] = await tasksModel.get(taskId);
|
||||
if (error) continue;
|
||||
integrityTasks.value[taskId] = result;
|
||||
if (!result.active) delete integrityTasks.value[taskId];
|
||||
if (!result.active) {
|
||||
integrityTasks.value[taskId].integrityCheckTaskId = null;
|
||||
delete integrityTasks.value[taskId];
|
||||
}
|
||||
}
|
||||
|
||||
const stillActive = Object.keys(integrityTasks.value).length !== 0;
|
||||
@@ -259,12 +262,18 @@ async function refreshIntegrityTasks() {
|
||||
}
|
||||
}
|
||||
|
||||
async function onCheckIntegrity(backup) {
|
||||
const [error, taskId] = await backupsModel.checkIntegrity(backup.id);
|
||||
async function onStartIntegrityCheck(backup) {
|
||||
const [error, taskId] = await backupsModel.startIntegrityCheck(backup.id);
|
||||
if (error) return window.cloudron.onError(error);
|
||||
backup.integrityCheckTaskId = taskId;
|
||||
integrityTasks.value[taskId] = {};
|
||||
await refreshIntegrityTasks();
|
||||
integrityTasks.value[taskId] = backup;
|
||||
}
|
||||
|
||||
async function onStopIntegrityCheck(backup) {
|
||||
const [error] = await backupsModel.stopIntegrityCheck(backup.id);
|
||||
if (error) return window.cloudron.onError(error);
|
||||
delete integrityTasks.value[backup.integrityCheckTaskId];
|
||||
backup.integrityCheckTaskId = null;
|
||||
}
|
||||
|
||||
async function onRestoreSubmit() {
|
||||
|
||||
Reference in New Issue
Block a user