commit 27804bb47c23a3387ab6a1112e14ea084bbe3535
parent e2d3cc3f0d95ede10bfbe778e312f649f1b8007d
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 30 Sep 2014 23:14:02 -0400
Fix database backup on userdata upgrade
Also uncomment standard backup age tests
Diffstat:
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js
@@ -624,6 +624,9 @@ Zotero.DBConnection.prototype.executeTransaction = Zotero.Promise.coroutine(func
Zotero.DBConnection.prototype.waitForTransaction = function () {
+ if (!this._transactionPromise) {
+ return Zotero.Promise.resolve();
+ }
Zotero.debug("Waiting for transaction to finish");
return this._transactionPromise.then(function () {
Zotero.debug("Done waiting for transaction");
@@ -955,7 +958,7 @@ Zotero.DBConnection.prototype.backupDatabase = Zotero.Promise.coroutine(function
}
}
- if (Zotero.locked) {
+ if (Zotero.locked && !force) {
this._debug("Zotero is locked -- skipping backup of DB '" + this._dbName + "'", 2);
return false;
}
@@ -987,7 +990,7 @@ Zotero.DBConnection.prototype.backupDatabase = Zotero.Promise.coroutine(function
var file = Zotero.getZoteroDatabase(this._dbName);
// For standard backup, make sure last backup is old enough to replace
- /*if (!suffix && !force) {
+ if (!suffix && !force) {
var backupFile = Zotero.getZoteroDatabase(this._dbName, 'bak');
if (yield OS.File.exists(backupFile.path)) {
var currentDBTime = (yield OS.File.stat(file.path)).lastModificationDate;
@@ -1006,7 +1009,7 @@ Zotero.DBConnection.prototype.backupDatabase = Zotero.Promise.coroutine(function
return;
}
}
- }*/
+ }
this._debug("Backing up database '" + this._dbName + "'");
diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js
@@ -99,7 +99,7 @@ Zotero.Schema = new function(){
// If upgrading userdata, make backup of database first
.then(function (schemaVersion) {
if (userdata < schemaVersion) {
- return Zotero.DB.backupDatabase(userdata);
+ return Zotero.DB.backupDatabase(userdata, true);
}
})
.then(function () {