From 3f75bf62d58cce59fc0821f7870ac61aebd19375 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 16 Feb 2018 18:03:16 -0800 Subject: [PATCH] check for recovery complete always, reload content page on restore --- .../resources/web/content/js/content.js | 11 +++++++++ .../src/DomainContentBackupManager.cpp | 23 ++++++++++--------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/domain-server/resources/web/content/js/content.js b/domain-server/resources/web/content/js/content.js index 4d8034eb1d..268cd2f5dd 100644 --- a/domain-server/resources/web/content/js/content.js +++ b/domain-server/resources/web/content/js/content.js @@ -5,6 +5,8 @@ $(document).ready(function(){ var UPLOAD_CONTENT_ALLOWED_DIV_ID = 'upload-content-allowed'; var UPLOAD_CONTENT_RECOVERING_DIV_ID = 'upload-content-recovering'; + var isRestoring = false; + function progressBarHTML(extraClass, label) { var html = "
"; html += "
"; @@ -64,6 +66,7 @@ $(document).ready(function(){ contentType: false, data: fileFormData }).done(function(data, textStatus, jqXHR) { + isRestoring = true; swal.close(); }).fail(function(jqXHR, textStatus, errorThrown) { showErrorMessage( @@ -138,6 +141,13 @@ $(document).ready(function(){ return value.isManualBackup; }); + if (isRestoring && !data.status.isRecovering) { + // we were recovering and we finished - the DS is going to restart so show the restart modal + showRestartModal(); + } + + isRestoring = data.status.isRecovering; + manualBackups = splitBackups[0]; automaticBackups = splitBackups[1]; @@ -270,6 +280,7 @@ $(document).ready(function(){ // setup an AJAX POST to request content restore $.post('/api/backups/recover/' + backupID).done(function(data, textStatus, jqXHR) { + isRestoring = true; swal.close(); }).fail(function(jqXHR, textStatus, errorThrown) { showErrorMessage( diff --git a/domain-server/src/DomainContentBackupManager.cpp b/domain-server/src/DomainContentBackupManager.cpp index a218ee87ea..d58b943317 100644 --- a/domain-server/src/DomainContentBackupManager.cpp +++ b/domain-server/src/DomainContentBackupManager.cpp @@ -132,19 +132,20 @@ bool DomainContentBackupManager::process() { int64_t sinceLastSave = now - _lastCheck; int64_t intervalToCheck = _persistInterval * MSECS_TO_USECS; + if (_isRecovering) { + bool isStillRecovering = any_of(begin(_backupHandlers), end(_backupHandlers), [](const BackupHandlerPointer& handler) { + return handler->getRecoveryStatus().first; + }); + + if (!isStillRecovering) { + _isRecovering = false; + _recoveryFilename = ""; + emit recoveryCompleted(); + } + } + if (sinceLastSave > intervalToCheck) { _lastCheck = now; - if (_isRecovering) { - bool isStillRecovering = any_of(begin(_backupHandlers), end(_backupHandlers), [](const BackupHandlerPointer& handler) { - return handler->getRecoveryStatus().first; - }); - - if (!isStillRecovering) { - _isRecovering = false; - _recoveryFilename = ""; - emit recoveryCompleted(); - } - } if (!_isRecovering) { backup();