commit bfbfd079102c78ac8a2c3c48a6d8608a60658e8b
parent 2f4de0e8030ea49653fdc0c1cb3e7f0a2a30ebe9
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 22 Feb 2011 02:45:31 +0000
Automatically correct invalid timestamps on sync error
Diffstat:
1 file changed, 27 insertions(+), 0 deletions(-)
diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js
@@ -1944,6 +1944,33 @@ Zotero.Sync.Server = new function () {
}, 1);
break;
+ case 'INVALID_TIMESTAMP':
+ var validClock = Zotero.DB.valueQuery("SELECT CURRENT_TIMESTAMP BETWEEN '1970-01-01 00:00:01' AND '2038-01-19 03:14:07'");
+ if (!validClock) {
+ // TODO: localize
+ _error("The system clock is set to an invalid time. You will need to correct this to sync with the Zotero server.");
+ }
+
+ setTimeout(function () {
+ Zotero.DB.beginTransaction();
+
+ var types = ['collections', 'creators', 'items', 'savedSearches', 'tags'];
+ for each (var type in types) {
+ var sql = "UPDATE " + type + " SET dateAdded=CURRENT_TIMESTAMP "
+ + "WHERE dateAdded NOT BETWEEN '1970-01-01 00:00:01' AND '2038-01-19 03:14:07'";
+ Zotero.DB.query(sql);
+ var sql = "UPDATE " + type + " SET dateModified=CURRENT_TIMESTAMP "
+ + "WHERE dateModified NOT BETWEEN '1970-01-01 00:00:01' AND '2038-01-19 03:14:07'";
+ Zotero.DB.query(sql);
+ var sql = "UPDATE " + type + " SET clientDateModified=CURRENT_TIMESTAMP "
+ + "WHERE clientDateModified NOT BETWEEN '1970-01-01 00:00:01' AND '2038-01-19 03:14:07'";
+ Zotero.DB.query(sql);
+ }
+
+ Zotero.DB.commitTransaction();
+ }, 1);
+ break;
+
case 'UPGRADE_REQUIRED':
Zotero.Sync.Server.upgradeRequired = true;
break;