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.
This commit is contained in:
Dan Stillman 2015-07-21 03:01:21 -04:00
parent 33334d9c01
commit 5fc2dd4d44
2 changed files with 22 additions and 2 deletions

View file

@ -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");

View file

@ -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) {