From 8e07effc0db8b5fa088148a5decd00053fccbe44 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 21 Jan 2009 20:20:27 +0000 Subject: [PATCH] Missed change from last week -- ensures that no two successive DB transactions use the same timestamp, to avoid some sync-related problems --- chrome/content/zotero/xpcom/db.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js index ec12232f2..1eccc5924 100644 --- 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