Disable "Check Database Integrity" button while running
This commit is contained in:
parent
a85ea18fd9
commit
6acf208a36
2 changed files with 69 additions and 63 deletions
|
@ -133,13 +133,15 @@ Zotero_Preferences.Advanced = {
|
|||
}),
|
||||
|
||||
|
||||
runIntegrityCheck: Zotero.Promise.coroutine(function* () {
|
||||
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
runIntegrityCheck: async function (button) {
|
||||
button.disabled = true;
|
||||
|
||||
var ok = yield Zotero.DB.integrityCheck();
|
||||
try {
|
||||
let ps = Services.prompt;
|
||||
|
||||
var ok = await Zotero.DB.integrityCheck();
|
||||
if (ok) {
|
||||
ok = yield Zotero.Schema.integrityCheck();
|
||||
ok = await Zotero.Schema.integrityCheck();
|
||||
if (!ok) {
|
||||
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
|
||||
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
|
||||
|
@ -155,13 +157,13 @@ Zotero_Preferences.Advanced = {
|
|||
|
||||
if (index == 0) {
|
||||
// Safety first
|
||||
yield Zotero.DB.backupDatabase();
|
||||
await Zotero.DB.backupDatabase();
|
||||
|
||||
// Fix the errors
|
||||
yield Zotero.Schema.integrityCheck(true);
|
||||
await Zotero.Schema.integrityCheck(true);
|
||||
|
||||
// And run the check again
|
||||
ok = yield Zotero.Schema.integrityCheck();
|
||||
ok = await Zotero.Schema.integrityCheck();
|
||||
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING);
|
||||
if (ok) {
|
||||
var str = 'success';
|
||||
|
@ -191,7 +193,7 @@ Zotero_Preferences.Advanced = {
|
|||
}
|
||||
|
||||
try {
|
||||
yield Zotero.DB.vacuum();
|
||||
await Zotero.DB.vacuum();
|
||||
}
|
||||
catch (e) {
|
||||
Zotero.logError(e);
|
||||
|
@ -204,7 +206,11 @@ Zotero_Preferences.Advanced = {
|
|||
Zotero.getString('general.' + str),
|
||||
Zotero.getString('db.integrityCheck.' + str)
|
||||
+ (!ok ? "\n\n" + Zotero.getString('db.integrityCheck.dbRepairTool') : ''));
|
||||
}),
|
||||
}
|
||||
finally {
|
||||
button.disabled = false;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
resetTranslatorsAndStyles: function () {
|
||||
|
|
|
@ -202,7 +202,7 @@
|
|||
|
||||
<hbox style="display: block">
|
||||
<button label="&zotero.preferences.dbMaintenance.integrityCheck;"
|
||||
oncommand="Zotero_Preferences.Advanced.runIntegrityCheck()"/>
|
||||
oncommand="Zotero_Preferences.Advanced.runIntegrityCheck(this)"/>
|
||||
<button id="reset-translators-button"
|
||||
label="&zotero.preferences.dbMaintenance.resetTranslators;"
|
||||
oncommand="Zotero_Preferences.Advanced.resetTranslators()"/>
|
||||
|
|
Loading…
Add table
Reference in a new issue