Fixed issue where restoring a DB backup would cause backup_local_db task to be stuck running

Slightly updated tasks UI
tasks-and-maintenence-page
Isaac Abadi 3 years ago
parent a288163644
commit d2d125743e

@ -110,7 +110,8 @@ exports.executeTask = async (task_key) => {
exports.executeRun = async (task_key) => {
logger.verbose(`Running task ${task_key}`);
await db_api.updateRecord('tasks', {key: task_key}, {running: true});
// don't set running to true when backup up DB as it will be stick "running" if restored
if (task_key !== 'backup_local_db') await db_api.updateRecord('tasks', {key: task_key}, {running: true});
const data = await TASKS[task_key].run();
await db_api.updateRecord('tasks', {key: task_key}, {data: data, last_ran: Date.now()/1000, running: false});
logger.verbose(`Finished running task ${task_key}`);

@ -34,9 +34,9 @@
<mat-header-cell *matHeaderCellDef mat-sort-header> <ng-container i18n="Status">Status</ng-container> </mat-header-cell>
<mat-cell *matCellDef="let element">
<span *ngIf="element.running || element.confirming"><mat-spinner matTooltip="Busy" i18n-matTooltip="Busy" [diameter]="25"></mat-spinner></span>
<span *ngIf="!(element.running || element.confirming) && element.schedule">
<span *ngIf="!(element.running || element.confirming) && element.schedule" style="display: flex">
<ng-container i18n="Scheduled">Scheduled for</ng-container>&nbsp;
{{element.next_invocation | date: 'short'}}<mat-icon style="font-size: 16px; text-align: center;" *ngIf="element.schedule.type === 'recurring'">repeat</mat-icon>
{{element.next_invocation | date: 'short'}}<mat-icon style="font-size: 16px; display: inline-flex; align-items: center; padding-left: 5px;" *ngIf="element.schedule.type === 'recurring'">repeat</mat-icon>
</span>
<span *ngIf="!(element.running || element.confirming) && !element.schedule">
<ng-container i18n="Not scheduled">Not scheduled</ng-container>
@ -58,10 +58,10 @@
</button>
</ng-container>
</div>
<div class="col-3" style="padding-right: 0px">
<div class="col-3">
<button (click)="runTask(element.key)" [disabled]="element.running || element.confirming" mat-icon-button matTooltip="Run" i18n-matTooltip="Run"><mat-icon>play_arrow</mat-icon></button>
</div>
<div class="col-3" style="padding-left: 0px">
<div class="col-3">
<button (click)="scheduleTask(element)" mat-icon-button matTooltip="Schedule" i18n-matTooltip="Schedule"><mat-icon>schedule</mat-icon></button>
</div>
</div>

@ -31,14 +31,18 @@ export class RestoreDbDialogComponent implements OnInit {
}
restoreClicked(): void {
this.restoring = true;
if (this.selected_backup.length !== 1) return;
this.postsService.restoreDBBackup(this.selected_backup[0]).subscribe(res => {
this.restoring = false;
if (res['success']) {
this.postsService.openSnackBar('Database successfully restored!');
this.dialogRef.close();
} else {
this.postsService.openSnackBar('Failed to restore database! See logs for more info.');
}
}, err => {
this.restoring = false;
this.postsService.openSnackBar('Failed to restore database! See browser console for more info.');
console.error(err);
});

Loading…
Cancel
Save