Backport better incompatible-DB-version handling from 2177a000ea
Implements #891 for 4.0
This commit is contained in:
parent
04d957a95c
commit
b05f1d29aa
|
@ -1298,3 +1298,9 @@ Zotero.DBConnection.prototype._getTypedValue = function (statement, i) {
|
|||
|
||||
// Initialize main database connection
|
||||
Zotero.DB = new Zotero.DBConnection('zotero');
|
||||
|
||||
Zotero.DB.IncompatibleVersionException = function (msg, dbClientVersion) {
|
||||
this.message = msg;
|
||||
this.dbClientVersion = dbClientVersion;
|
||||
}
|
||||
Zotero.DB.IncompatibleVersionException.prototype = Object.create(Error.prototype);
|
||||
|
|
|
@ -1554,8 +1554,12 @@ Zotero.Schema = new function(){
|
|||
return true;
|
||||
}
|
||||
|
||||
throw ("Zotero '" + schema + "' DB version (" + dbVersion
|
||||
+ ") is newer than SQL file (" + schemaVersion + ")");
|
||||
let dbClientVersion = Zotero.DB.valueQuery(
|
||||
"SELECT value FROM settings WHERE setting='client' AND key='lastCompatibleVersion'"
|
||||
);
|
||||
let msg = "Database is incompatible with this Zotero version "
|
||||
+ `(${schema}: ${schemaVersion} > ${dbVersion})`
|
||||
throw new Zotero.DB.IncompatibleVersionException(msg, dbClientVersion);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1937,8 +1941,12 @@ Zotero.Schema = new function(){
|
|||
return false;
|
||||
}
|
||||
else if (fromVersion > toVersion) {
|
||||
throw new Error("Zotero user data DB version is newer than SQL file "
|
||||
+ "(" + toVersion + " < " + fromVersion + ")");
|
||||
let dbClientVersion = Zotero.DB.valueQuery(
|
||||
"SELECT value FROM settings WHERE setting='client' AND key='lastCompatibleVersion'"
|
||||
);
|
||||
let msg = "Database is incompatible with this Zotero version "
|
||||
+ `(user data: ${fromVersion} > ${toVersion})`
|
||||
throw new Zotero.DB.IncompatibleVersionException(msg, dbClientVersion);
|
||||
}
|
||||
|
||||
Zotero.debug('Updating user data tables from version ' + fromVersion + ' to ' + toVersion);
|
||||
|
|
|
@ -610,20 +610,23 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
|||
var updated = Zotero.Schema.updateSchema();
|
||||
}
|
||||
catch (e) {
|
||||
if (e.toString().match('newer than SQL file')) {
|
||||
let versions = e.toString().match(/\((\d+) < (\d+)\)/);
|
||||
if (e instanceof Zotero.DB.IncompatibleVersionException) {
|
||||
let kbURL = "https://www.zotero.org/support/kb/newer_db_version";
|
||||
let msg = Zotero.getString('startupError.zoteroVersionIsOlder') + " "
|
||||
+ Zotero.getString('startupError.zoteroVersionIsOlder.upgrade') + "\n\n"
|
||||
let msg = (e.dbClientVersion
|
||||
? Zotero.getString('startupError.incompatibleDBVersion',
|
||||
[Zotero.clientName, e.dbClientVersion])
|
||||
: Zotero.getString('startupError.zoteroVersionIsOlder')) + "\n\n"
|
||||
+ Zotero.getString('startupError.zoteroVersionIsOlder.current', Zotero.version)
|
||||
+ (versions ? " (" + versions[1] + " < " + versions[2] + ")" : "") + "\n\n"
|
||||
+ Zotero.getString('general.seeForMoreInformation', kbURL);
|
||||
+ "\n\n"
|
||||
+ Zotero.getString('startupError.zoteroVersionIsOlder.upgrade',
|
||||
ZOTERO_CONFIG.DOMAIN_NAME);
|
||||
Zotero.startupError = msg;
|
||||
_startupErrorHandler = function() {
|
||||
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
|
||||
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
|
||||
+ (ps.BUTTON_POS_2) * (ps.BUTTON_TITLE_IS_STRING)
|
||||
+ ps.BUTTON_POS_0_DEFAULT;
|
||||
|
||||
var index = ps.confirmEx(
|
||||
|
@ -632,10 +635,13 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
|||
Zotero.startupError,
|
||||
buttonFlags,
|
||||
Zotero.getString('general.checkForUpdate'),
|
||||
null, null, null, {}
|
||||
null,
|
||||
Zotero.getString('general.moreInformation'),
|
||||
null,
|
||||
{}
|
||||
);
|
||||
|
||||
// "Check for updates" button
|
||||
// "Check for Update" button
|
||||
if(index === 0) {
|
||||
if(Zotero.isStandalone) {
|
||||
Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
||||
|
@ -680,6 +686,17 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
|||
);
|
||||
}
|
||||
}
|
||||
// Load More Info page
|
||||
else if (index == 2) {
|
||||
let io = Components.classes['@mozilla.org/network/io-service;1']
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
let uri = io.newURI(kbURL, null, null);
|
||||
let handler = Components.classes['@mozilla.org/uriloader/external-protocol-service;1']
|
||||
.getService(Components.interfaces.nsIExternalProtocolService)
|
||||
.getProtocolHandlerInfo('http');
|
||||
handler.preferredAction = Components.interfaces.nsIHandlerInfo.useSystemDefault;
|
||||
handler.launchWithURI(uri, null);
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -133,8 +133,9 @@ startupError.closeFirefox = If Firefox with the Zotero extension is open, pl
|
|||
startupError.databaseCannotBeOpened = The Zotero database cannot be opened.
|
||||
startupError.checkPermissions = Make sure you have read and write permissions for all files in the Zotero data directory.
|
||||
startupError.zoteroVersionIsOlder = This version of Zotero is older than the version last used with your database.
|
||||
startupError.zoteroVersionIsOlder.upgrade = Please upgrade to the latest version from zotero.org.
|
||||
startupError.incompatibleDBVersion = This %1$S database requires %1$S %2$S or later.
|
||||
startupError.zoteroVersionIsOlder.current = Current version: %S
|
||||
startupError.zoteroVersionIsOlder.upgrade = Please upgrade to the latest version from %S.
|
||||
startupError.databaseUpgradeError = Database upgrade error
|
||||
|
||||
date.relative.secondsAgo.one = 1 second ago
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var ZOTERO_CONFIG = {
|
||||
GUID: 'zotero@chnm.gmu.edu',
|
||||
CLIENT_NAME: 'Zotero',
|
||||
DOMAIN_NAME: 'zotero.org',
|
||||
REPOSITORY_URL: 'https://repo.zotero.org/repo/',
|
||||
REPOSITORY_CHECK_INTERVAL: 86400, // 24 hours
|
||||
REPOSITORY_RETRY_INTERVAL: 3600, // 1 hour
|
||||
|
|
Loading…
Reference in New Issue
Block a user