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() {
|
||||
|
||||
@@ -32,10 +32,10 @@ function create() {
|
||||
if (error || result.status !== 200) return [error || result];
|
||||
return [null];
|
||||
},
|
||||
async checkIntegrity(id) {
|
||||
async startIntegrityCheck(id) {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.post(`${API_ORIGIN}/api/v1/backups/${id}/check_integrity`, {}, { access_token: accessToken });
|
||||
result = await fetcher.post(`${API_ORIGIN}/api/v1/backups/${id}/start_integrity_check`, {}, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
@@ -43,6 +43,17 @@ function create() {
|
||||
if (error || result.status !== 201) return [error || result];
|
||||
return [null, result.body.taskId];
|
||||
},
|
||||
async stopIntegrityCheck(id) {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.post(`${API_ORIGIN}/api/v1/backups/${id}/stop_integrity_check`, {}, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
if (error || result.status !== 204) return [error || result];
|
||||
return [null];
|
||||
},
|
||||
async get(id) {
|
||||
let error, result;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user