commit 5fc2dd4d44bb226aa06517b67d66396e14b1f474
parent 33334d9c018cdba2f78729e548e46d8dd68c9471
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 21 Jul 2015 03:01:21 -0400
Fix a probably rare case of a file's not being uploaded
If a file existed locally but somehow ended up marked as to-download without
existing on the server, it was never uploaded. I'm not sure when this can
happen, but I saw it while messing around. Maybe switching between ZFS and
WebDAV?
This will still only check and upload if there's another computer syncing files
to the same library, but we'll check all files in 5.0.
Diffstat:
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/chrome/content/zotero/xpcom/storage/webdav.js b/chrome/content/zotero/xpcom/storage/webdav.js
@@ -853,15 +853,25 @@ Zotero.Sync.Storage.WebDAV = (function () {
return false;
}
+ var file = item.getFile();
+
if (!mdate) {
Zotero.debug("Remote file not found for item " + Zotero.Items.getLibraryKeyHash(item));
+ // Reset sync state if a remotely missing file exists locally.
+ // I'm not sure how this can happen, but otherwise it results in
+ // a file marked as TO_DOWNLOAD never being uploaded.
+ if (file && file.exists()) {
+ Zotero.Sync.Storage.setSyncState(item.id, Zotero.Sync.Storage.SYNC_STATE_TO_UPLOAD);
+ return {
+ localChanges: true
+ };
+ }
return false;
}
var syncModTime = mdate.getTime();
// Skip download if local file exists and matches mod time
- var file = item.getFile();
if (file && file.exists() && syncModTime == file.lastModifiedTime) {
Zotero.debug("File mod time matches remote file -- skipping download");
diff --git a/chrome/content/zotero/xpcom/storage/zfs.js b/chrome/content/zotero/xpcom/storage/zfs.js
@@ -762,15 +762,25 @@ Zotero.Sync.Storage.ZFS = (function () {
return false;
}
+ var file = item.getFile();
+
if (!info) {
Zotero.debug("Remote file not found for item " + item.libraryID + "/" + item.key);
+ // Reset sync state if a remotely missing file exists locally.
+ // I'm not sure how this can happen, but otherwise it results in
+ // a file marked as TO_DOWNLOAD never being uploaded.
+ if (file && file.exists()) {
+ Zotero.Sync.Storage.setSyncState(item.id, Zotero.Sync.Storage.SYNC_STATE_TO_UPLOAD);
+ return {
+ localChanges: true
+ };
+ }
return false;
}
var syncModTime = info.mtime;
var syncHash = info.hash;
- var file = item.getFile();
// Skip download if local file exists and matches mod time
if (file && file.exists()) {
if (syncModTime == file.lastModifiedTime) {