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