www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 8e07effc0db8b5fa088148a5decd00053fccbe44
parent 0208806a9557dbad4f3b72e4ef4fafa5f001867d
Author: Dan Stillman <dstillman@zotero.org>
Date:   Wed, 21 Jan 2009 20:20:27 +0000

Missed change from last week -- ensures that no two successive DB transactions use the same timestamp, to avoid some sync-related problems


Diffstat:
Mchrome/content/zotero/xpcom/db.js | 12++++++++++++
1 file changed, 12 insertions(+), 0 deletions(-)

diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js @@ -53,6 +53,7 @@ Zotero.DBConnection = function(dbName) { this._shutdown = false; this._connection = null; this._transactionDate = null; + this._lastTransactionDate = null; this._transactionRollback = null; this._transactionNestingLevel = 0; this._callbacks = { begin: [], commit: [], rollback: [] }; @@ -358,6 +359,14 @@ Zotero.DBConnection.prototype.beginTransaction = function () { // Set a timestamp for this transaction this._transactionDate = new Date(Math.floor(new Date / 1000) * 1000); + // If transaction time hasn't changed since last transaction, + // add a second -- this is a hack to get around a sync problem when + // multiple sync sessions run within the same second + if (this._lastTransactionDate && + this._transactionDate.getTime() <= this._lastTransactionDate.getTime()) { + this._transactionDate = new Date(this._lastTransactionDate.getTime() + 1000) + } + // Run callbacks for (var i=0; i<this._callbacks.begin.length; i++) { if (this._callbacks.begin[i]) { @@ -382,6 +391,9 @@ Zotero.DBConnection.prototype.commitTransaction = function () { else { this._debug('Committing transaction',5); + if (this._transactionDate) { + this._lastTransactionDate = this._transactionDate; + } // Clear transaction timestamp this._transactionDate = null;