check for recovery complete always, reload content page on restore

This commit is contained in:
Stephen Birarda 2018-02-16 18:03:16 -08:00
parent 769d5677b1
commit 3f75bf62d5
2 changed files with 23 additions and 11 deletions

View file

@ -5,6 +5,8 @@ $(document).ready(function(){
var UPLOAD_CONTENT_ALLOWED_DIV_ID = 'upload-content-allowed'; var UPLOAD_CONTENT_ALLOWED_DIV_ID = 'upload-content-allowed';
var UPLOAD_CONTENT_RECOVERING_DIV_ID = 'upload-content-recovering'; var UPLOAD_CONTENT_RECOVERING_DIV_ID = 'upload-content-recovering';
var isRestoring = false;
function progressBarHTML(extraClass, label) { function progressBarHTML(extraClass, label) {
var html = "<div class='progress'>"; var html = "<div class='progress'>";
html += "<div class='" + extraClass + " progress-bar progress-bar-success progress-bar-striped active' role='progressbar' aria-valuemin='0' aria-valuemax='100'>"; html += "<div class='" + extraClass + " progress-bar progress-bar-success progress-bar-striped active' role='progressbar' aria-valuemin='0' aria-valuemax='100'>";
@ -64,6 +66,7 @@ $(document).ready(function(){
contentType: false, contentType: false,
data: fileFormData data: fileFormData
}).done(function(data, textStatus, jqXHR) { }).done(function(data, textStatus, jqXHR) {
isRestoring = true;
swal.close(); swal.close();
}).fail(function(jqXHR, textStatus, errorThrown) { }).fail(function(jqXHR, textStatus, errorThrown) {
showErrorMessage( showErrorMessage(
@ -138,6 +141,13 @@ $(document).ready(function(){
return value.isManualBackup; 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]; manualBackups = splitBackups[0];
automaticBackups = splitBackups[1]; automaticBackups = splitBackups[1];
@ -270,6 +280,7 @@ $(document).ready(function(){
// setup an AJAX POST to request content restore // setup an AJAX POST to request content restore
$.post('/api/backups/recover/' + backupID).done(function(data, textStatus, jqXHR) { $.post('/api/backups/recover/' + backupID).done(function(data, textStatus, jqXHR) {
isRestoring = true;
swal.close(); swal.close();
}).fail(function(jqXHR, textStatus, errorThrown) { }).fail(function(jqXHR, textStatus, errorThrown) {
showErrorMessage( showErrorMessage(

View file

@ -132,19 +132,20 @@ bool DomainContentBackupManager::process() {
int64_t sinceLastSave = now - _lastCheck; int64_t sinceLastSave = now - _lastCheck;
int64_t intervalToCheck = _persistInterval * MSECS_TO_USECS; 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) { if (sinceLastSave > intervalToCheck) {
_lastCheck = now; _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) { if (!_isRecovering) {
backup(); backup();