commit 65a39417bf931bf08a82ba7eda23b713e3909f9f
parent a1710c3307ec0e8b71bd2afa607b93a4ec700b11
Author: Dan Stillman <dstillman@zotero.org>
Date: Wed, 16 Nov 2016 12:41:49 -0500
Closes #1112, Show "Upgrading database…" message
Diffstat:
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js
@@ -72,7 +72,7 @@ Zotero.Schema = new function(){
/*
* Checks if the DB schema exists and is up-to-date, updating if necessary
*/
- this.updateSchema = Zotero.Promise.coroutine(function* () {
+ this.updateSchema = Zotero.Promise.coroutine(function* (options = {}) {
// TODO: Check database integrity first with Zotero.DB.integrityCheck()
// 'userdata' is the last upgrade step run in _migrateUserDataSchema() based on the
@@ -133,7 +133,7 @@ Zotero.Schema = new function(){
if (Zotero.DB.tableExists('customItemTypes')) {
yield _updateCustomTables(updated);
}
- updated = yield _migrateUserDataSchema(userdata);
+ updated = yield _migrateUserDataSchema(userdata, options);
yield _updateSchema('triggers');
// Populate combined tables for custom types and fields -- this is likely temporary
@@ -1859,7 +1859,7 @@ Zotero.Schema = new function(){
//
// If libraryID set, make sure no relations still use a local user key, and then remove on-error code in sync.js
- var _migrateUserDataSchema = Zotero.Promise.coroutine(function* (fromVersion) {
+ var _migrateUserDataSchema = Zotero.Promise.coroutine(function* (fromVersion, options = {}) {
var toVersion = yield _getSchemaSQLVersion('userdata');
if (fromVersion >= toVersion) {
@@ -1868,6 +1868,13 @@ Zotero.Schema = new function(){
Zotero.debug('Updating user data tables from version ' + fromVersion + ' to ' + toVersion);
+ if (options.onBeforeUpdate) {
+ let maybePromise = options.onBeforeUpdate()
+ if (maybePromise && maybePromise.then) {
+ yield maybePromise;
+ }
+ }
+
Zotero.DB.requireTransaction();
// Step through version changes until we reach the current version
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -561,7 +561,11 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
}
try {
- var updated = yield Zotero.Schema.updateSchema();
+ var updated = yield Zotero.Schema.updateSchema({
+ onBeforeUpdate: () => Zotero.showZoteroPaneProgressMeter(
+ Zotero.getString('upgrade.status')
+ )
+ });
}
catch (e) {
Zotero.logError(e);
diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties
@@ -72,6 +72,7 @@ install.quickStartGuide.message.welcome = Welcome to Zotero!
install.quickStartGuide.message.view = View the Quick Start Guide to learn how to begin collecting, managing, citing, and sharing your research sources.
install.quickStartGuide.message.thanks = Thanks for installing Zotero.
+upgrade.status = Upgrading database…
upgrade.failed.title = Upgrade Failed
upgrade.failed = Upgrading of the Zotero database failed:
upgrade.advanceMessage = Press %S to upgrade now.