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
|
// Initialize main database connection
|
||||||
Zotero.DB = new Zotero.DBConnection('zotero');
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw ("Zotero '" + schema + "' DB version (" + dbVersion
|
let dbClientVersion = Zotero.DB.valueQuery(
|
||||||
+ ") is newer than SQL file (" + schemaVersion + ")");
|
"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;
|
return false;
|
||||||
}
|
}
|
||||||
else if (fromVersion > toVersion) {
|
else if (fromVersion > toVersion) {
|
||||||
throw new Error("Zotero user data DB version is newer than SQL file "
|
let dbClientVersion = Zotero.DB.valueQuery(
|
||||||
+ "(" + toVersion + " < " + fromVersion + ")");
|
"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);
|
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();
|
var updated = Zotero.Schema.updateSchema();
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
if (e.toString().match('newer than SQL file')) {
|
if (e instanceof Zotero.DB.IncompatibleVersionException) {
|
||||||
let versions = e.toString().match(/\((\d+) < (\d+)\)/);
|
|
||||||
let kbURL = "https://www.zotero.org/support/kb/newer_db_version";
|
let kbURL = "https://www.zotero.org/support/kb/newer_db_version";
|
||||||
let msg = Zotero.getString('startupError.zoteroVersionIsOlder') + " "
|
let msg = (e.dbClientVersion
|
||||||
+ Zotero.getString('startupError.zoteroVersionIsOlder.upgrade') + "\n\n"
|
? Zotero.getString('startupError.incompatibleDBVersion',
|
||||||
|
[Zotero.clientName, e.dbClientVersion])
|
||||||
|
: Zotero.getString('startupError.zoteroVersionIsOlder')) + "\n\n"
|
||||||
+ Zotero.getString('startupError.zoteroVersionIsOlder.current', Zotero.version)
|
+ Zotero.getString('startupError.zoteroVersionIsOlder.current', Zotero.version)
|
||||||
+ (versions ? " (" + versions[1] + " < " + versions[2] + ")" : "") + "\n\n"
|
+ "\n\n"
|
||||||
+ Zotero.getString('general.seeForMoreInformation', kbURL);
|
+ Zotero.getString('startupError.zoteroVersionIsOlder.upgrade',
|
||||||
|
ZOTERO_CONFIG.DOMAIN_NAME);
|
||||||
Zotero.startupError = msg;
|
Zotero.startupError = msg;
|
||||||
_startupErrorHandler = function() {
|
_startupErrorHandler = function() {
|
||||||
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||||
.getService(Components.interfaces.nsIPromptService);
|
.getService(Components.interfaces.nsIPromptService);
|
||||||
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)
|
||||||
|
+ (ps.BUTTON_POS_2) * (ps.BUTTON_TITLE_IS_STRING)
|
||||||
+ ps.BUTTON_POS_0_DEFAULT;
|
+ ps.BUTTON_POS_0_DEFAULT;
|
||||||
|
|
||||||
var index = ps.confirmEx(
|
var index = ps.confirmEx(
|
||||||
|
@ -632,10 +635,13 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
||||||
Zotero.startupError,
|
Zotero.startupError,
|
||||||
buttonFlags,
|
buttonFlags,
|
||||||
Zotero.getString('general.checkForUpdate'),
|
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(index === 0) {
|
||||||
if(Zotero.isStandalone) {
|
if(Zotero.isStandalone) {
|
||||||
Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
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 {
|
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.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.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 = 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.current = Current version: %S
|
||||||
|
startupError.zoteroVersionIsOlder.upgrade = Please upgrade to the latest version from %S.
|
||||||
startupError.databaseUpgradeError = Database upgrade error
|
startupError.databaseUpgradeError = Database upgrade error
|
||||||
|
|
||||||
date.relative.secondsAgo.one = 1 second ago
|
date.relative.secondsAgo.one = 1 second ago
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
var ZOTERO_CONFIG = {
|
var ZOTERO_CONFIG = {
|
||||||
GUID: 'zotero@chnm.gmu.edu',
|
GUID: 'zotero@chnm.gmu.edu',
|
||||||
CLIENT_NAME: 'Zotero',
|
CLIENT_NAME: 'Zotero',
|
||||||
|
DOMAIN_NAME: 'zotero.org',
|
||||||
REPOSITORY_URL: 'https://repo.zotero.org/repo/',
|
REPOSITORY_URL: 'https://repo.zotero.org/repo/',
|
||||||
REPOSITORY_CHECK_INTERVAL: 86400, // 24 hours
|
REPOSITORY_CHECK_INTERVAL: 86400, // 24 hours
|
||||||
REPOSITORY_RETRY_INTERVAL: 3600, // 1 hour
|
REPOSITORY_RETRY_INTERVAL: 3600, // 1 hour
|
||||||
|
|
Loading…
Reference in New Issue
Block a user