Added a mechanism to detect a corrupt/broken config database file. Fixes #6460

This commit is contained in:
Nikhil Mohite
2021-06-08 19:41:47 +05:30
committed by Akshay Joshi
parent 93ddc4a5ba
commit 7c88ee7cff
7 changed files with 137 additions and 9 deletions

View File

@@ -594,7 +594,7 @@ define('pgadmin.browser', [
}, 300000);
obj.set_master_password('');
obj.check_corrupted_db_file();
obj.Events.on('pgadmin:browser:tree:add', obj.onAddTreeNode, obj);
obj.Events.on('pgadmin:browser:tree:update', obj.onUpdateTreeNode, obj);
obj.Events.on('pgadmin:browser:tree:refresh', obj.onRefreshTreeNode, obj);
@@ -607,7 +607,35 @@ define('pgadmin.browser', [
obj.register_to_activity_listener(document);
obj.start_inactivity_timeout_daemon();
},
check_corrupted_db_file: function() {
$.ajax({
url: url_for('browser.check_corrupted_db_file'),
type: 'GET',
dataType: 'json',
contentType: 'application/json',
}).done((res)=> {
if(res.data.length > 0) {
Alertify.alert(
'Warning',
'pgAdmin detected unrecoverable corruption in it\'s SQLite configuration database. ' +
'The database has been backed up and recreated with default settings. '+
'It may be possible to recover data such as query history manually from '+
'the original/corrupt file using a tool such as DB Browser for SQLite if desired.'+
'<br><br>Original file: ' + res.data + '<br>Replacement file: ' +
res.data.substring(0, res.data.length - 14)
)
.set({'closable': true,
'onok': function() {
},
});
}
}).fail(function(xhr, status, error) {
Alertify.alert(error);
});
},
init_master_password: function() {
let self = this;
// Master password dialog