Skip to content

Commit

Permalink
Merge pull request duplicati#5282 from duplicati/feature/improved-tas…
Browse files Browse the repository at this point in the history
…k-when-completes

Separating the timers and callbacks
  • Loading branch information
kenkendk authored Jul 19, 2024
2 parents 2f26f52 + 9cd94bb commit abe37e7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Duplicati/Server/webroot/ngax/scripts/services/ServerStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ backupApp.service('ServerStatus', function ($rootScope, $timeout, AppService, Ap

this.callWhenTaskCompletes = function (taskid, callback) {
if (waitingfortask[taskid] == null)
{
waitingfortask[taskid] = [];

// Guard against cases where the taks state is incorrectly reported
// This happens on really fast completion, and also sometimes on longer running tasks
waitingfortask[taskid].push(callback);

// Guard against cases where the taks state is incorrectly reported
// This happens on really fast completion, and also sometimes on longer running tasks
if (waitingfortaskTimers[taskid] == null) {
waitingfortaskTimers[taskid] = window.setInterval(() => {
if (waitingfortask[taskid] == null)
{
Expand All @@ -141,8 +143,7 @@ backupApp.service('ServerStatus', function ($rootScope, $timeout, AppService, Ap
checkTaskState(taskid);
}, 1000);
}

waitingfortask[taskid].push(callback);

};

// This appears to be broken, and causes the UI to hang
Expand Down

0 comments on commit abe37e7

Please sign in to comment.