From 65a39417bf931bf08a82ba7eda23b713e3909f9f Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 16 Nov 2016 12:41:49 -0500 Subject: [PATCH] =?UTF-8?q?Closes=20#1112,=20Show=20"Upgrading=20database?= =?UTF-8?q?=E2=80=A6"=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chrome/content/zotero/xpcom/schema.js | 13 ++++++++++--- chrome/content/zotero/xpcom/zotero.js | 6 +++++- chrome/locale/en-US/zotero/zotero.properties | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index fdf6e10d4..18705de22 100644 --- 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 index cbfd41e3b..6843df52e 100644 --- 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 index 147f18397..876f5ffe6 100644 --- 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.