commit 045e2b083031baef487831358047e9c3a6a28815
parent bd69d272c52038659cfcd24beeb8edf4fe6358bf
Author: Dan Stillman <dstillman@zotero.org>
Date: Fri, 7 Aug 2009 13:32:36 +0000
Fix incessant file syncs and related file sync weirdness, I think
Diffstat:
1 file changed, 21 insertions(+), 22 deletions(-)
diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js
@@ -693,12 +693,12 @@ Zotero.Sync.Storage = new function () {
var file = item.getFile();
if (file && file.exists()
&& syncModTime == Math.round(file.lastModifiedTime / 1000)) {
- Zotero.debug("Stored file mod time matches remote file -- skipping download");
+ Zotero.debug("File mod time matches remote file -- skipping download");
Zotero.DB.beginTransaction();
var syncState = Zotero.Sync.Storage.getSyncState(item.id);
var updateItem = syncState != 1;
- Zotero.Sync.Storage.setSyncedModificationTime(item.id, syncModTime, true);
+ Zotero.Sync.Storage.setSyncedModificationTime(item.id, syncModTime, updateItem);
Zotero.Sync.Storage.setSyncState(item.id, Zotero.Sync.Storage.SYNC_STATE_IN_SYNC);
Zotero.DB.commitTransaction();
_changesMade = true;
@@ -1289,21 +1289,17 @@ Zotero.Sync.Storage = new function () {
if (Zotero.Sync.Storage.getSyncState(item.id)
!= Zotero.Sync.Storage.SYNC_STATE_FORCE_UPLOAD) {
if (mdate) {
+ // Remote prop time
var mtime = Zotero.Date.toUnixTimestamp(mdate);
- var smtime = Zotero.Sync.Storage.getSyncedModificationTime(item.id);
- // If file has been uploaded to storage server but there's
- // no local record of the time (e.g., due to a reset?),
- // use local file's time
- if (!smtime) {
- smtime = item.attachmentModificationTime;
- }
+ // Local file time
+ var fmtime = item.attachmentModificationTime;
- if (smtime == mtime) {
- Zotero.debug("Stored file mod time matches remote file -- skipping upload");
+ if (fmtime == mtime) {
+ Zotero.debug("File mod time matches remote file -- skipping upload");
Zotero.DB.beginTransaction();
var syncState = Zotero.Sync.Storage.getSyncState(item.id);
- Zotero.Sync.Storage.setSyncedModificationTime(item.id, smtime, true);
+ Zotero.Sync.Storage.setSyncedModificationTime(item.id, fmtime, true);
Zotero.Sync.Storage.setSyncState(item.id, Zotero.Sync.Storage.SYNC_STATE_IN_SYNC);
Zotero.DB.commitTransaction();
_changesMade = true;
@@ -1311,16 +1307,19 @@ Zotero.Sync.Storage = new function () {
return;
}
- var localData = { modTime: smtime };
- var remoteData = { modTime: mtime };
- Zotero.Sync.Storage.QueueManager.addConflict(
- request.name, localData, remoteData
- );
- Zotero.debug("Conflict -- last synced file mod time "
- + "does not match time on storage server"
- + " (" + smtime + " != " + mtime + ")");
- request.finish();
- return;
+ var smtime = Zotero.Sync.Storage.getSyncedModificationTime(item.id);
+ if (smtime != mtime) {
+ var localData = { modTime: smtime };
+ var remoteData = { modTime: mtime };
+ Zotero.Sync.Storage.QueueManager.addConflict(
+ request.name, localData, remoteData
+ );
+ Zotero.debug("Conflict -- last synced file mod time "
+ + "does not match time on storage server"
+ + " (" + smtime + " != " + mtime + ")");
+ request.finish();
+ return;
+ }
}
else {
Zotero.debug("Remote file not found for item " + item.id);