Missed change from last week -- ensures that no two successive DB transactions use the same timestamp, to avoid some sync-related problems
This commit is contained in:
parent
0208806a95
commit
8e07effc0d
|
@ -53,6 +53,7 @@ Zotero.DBConnection = function(dbName) {
|
||||||
this._shutdown = false;
|
this._shutdown = false;
|
||||||
this._connection = null;
|
this._connection = null;
|
||||||
this._transactionDate = null;
|
this._transactionDate = null;
|
||||||
|
this._lastTransactionDate = null;
|
||||||
this._transactionRollback = null;
|
this._transactionRollback = null;
|
||||||
this._transactionNestingLevel = 0;
|
this._transactionNestingLevel = 0;
|
||||||
this._callbacks = { begin: [], commit: [], rollback: [] };
|
this._callbacks = { begin: [], commit: [], rollback: [] };
|
||||||
|
@ -358,6 +359,14 @@ Zotero.DBConnection.prototype.beginTransaction = function () {
|
||||||
// Set a timestamp for this transaction
|
// Set a timestamp for this transaction
|
||||||
this._transactionDate = new Date(Math.floor(new Date / 1000) * 1000);
|
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
|
// Run callbacks
|
||||||
for (var i=0; i<this._callbacks.begin.length; i++) {
|
for (var i=0; i<this._callbacks.begin.length; i++) {
|
||||||
if (this._callbacks.begin[i]) {
|
if (this._callbacks.begin[i]) {
|
||||||
|
@ -382,6 +391,9 @@ Zotero.DBConnection.prototype.commitTransaction = function () {
|
||||||
else {
|
else {
|
||||||
this._debug('Committing transaction',5);
|
this._debug('Committing transaction',5);
|
||||||
|
|
||||||
|
if (this._transactionDate) {
|
||||||
|
this._lastTransactionDate = this._transactionDate;
|
||||||
|
}
|
||||||
// Clear transaction timestamp
|
// Clear transaction timestamp
|
||||||
this._transactionDate = null;
|
this._transactionDate = null;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user