Remove <=Fx24 file sync code

This commit is contained in:
Dan Stillman 2015-07-21 02:53:17 -04:00
parent da5e1272f7
commit 1fadf1150e

View file

@ -821,135 +821,6 @@ Zotero.Sync.Storage = new function () {
var numItems = items.length;
var updatedStates = {};
// OS.File didn't work reliably before Firefox 23, and on Windows it returns
// the access time instead of the modification time until Firefox 24
// (https://bugzilla.mozilla.org/show_bug.cgi?id=899436),
// so use the old code
if (Zotero.platformMajorVersion < 23
|| (Zotero.isWin && Zotero.platformMajorVersion < 24)) {
Zotero.debug("Performing synchronous file update check");
for each(var item in items) {
// Spin the event loop during synchronous file access
yield Q.delay(1);
//Zotero.debug("Memory usage: " + memmgr.resident);
let row = attachmentData[item.id];
let lk = item.libraryID + "/" + item.key;
//Zotero.debug("Checking attachment file for item " + lk);
var file = item.getFile(row);
if (!file) {
Zotero.debug("Marking attachment " + lk + " as missing");
updatedStates[item.id] = Zotero.Sync.Storage.SYNC_STATE_TO_DOWNLOAD;
continue;
}
// If file is already marked for upload, skip check. Even if this
// is download-marking mode (itemModTimes) and the file was
// changed remotely, conflicts are checked at upload time, so we
// don't need to worry about it here.
if (row.state == Zotero.Sync.Storage.SYNC_STATE_TO_UPLOAD) {
continue;
}
var fmtime = item.attachmentModificationTime;
//Zotero.debug("Stored mtime is " + row.mtime);
//Zotero.debug("File mtime is " + fmtime);
// Download-marking mode
if (itemModTimes) {
Zotero.debug("Remote mod time for item " + lk + " is " + itemModTimes[item.id]);
// Ignore attachments whose stored mod times haven't changed
if (row.storageModTime == itemModTimes[item.id]) {
Zotero.debug("Storage mod time (" + row.storageModTime + ") "
+ "hasn't changed for item " + lk);
continue;
}
Zotero.debug("Marking attachment " + lk + " for download "
+ "(stored mtime: " + itemModTimes[item.id] + ")");
updatedStates[item.id] = Zotero.Sync.Storage.SYNC_STATE_FORCE_DOWNLOAD;
}
var mtime = row.mtime;
// If stored time matches file, it hasn't changed locally
if (mtime == fmtime) {
continue;
}
// Allow floored timestamps for filesystems that don't support
// millisecond precision (e.g., HFS+)
if (Math.floor(mtime / 1000) * 1000 == fmtime || Math.floor(fmtime / 1000) * 1000 == mtime) {
Zotero.debug("File mod times are within one-second precision "
+ "(" + fmtime + " ≅ " + mtime + ") for " + file.leafName
+ " for item " + lk + " -- ignoring");
continue;
}
// Allow timestamp to be exactly one hour off to get around
// time zone issues -- there may be a proper way to fix this
if (Math.abs(fmtime - mtime) == 3600000
// And check with one-second precision as well
|| Math.abs(fmtime - Math.floor(mtime / 1000) * 1000) == 3600000
|| Math.abs(Math.floor(fmtime / 1000) * 1000 - mtime) == 3600000) {
Zotero.debug("File mod time (" + fmtime + ") is exactly one "
+ "hour off remote file (" + mtime + ") for item " + lk
+ "-- assuming time zone issue and skipping upload");
continue;
}
// If file hash matches stored hash, only the mod time changed, so skip
var f = item.getFile();
if (f) {
Zotero.debug(f.path);
}
else {
Zotero.debug("File for item " + lk + " missing before getting hash");
}
var fileHash = item.attachmentHash;
if (row.hash && row.hash == fileHash) {
Zotero.debug("Mod time didn't match (" + fmtime + "!=" + mtime + ") "
+ "but hash did for " + file.leafName + " for item " + lk
+ " -- updating file mod time");
try {
file.lastModifiedTime = row.mtime;
}
catch (e) {
Zotero.File.checkFileAccessError(e, file, 'update');
}
continue;
}
// Mark file for upload
Zotero.debug("Marking attachment " + lk + " as changed "
+ "(" + mtime + " != " + fmtime + ")");
updatedStates[item.id] = Zotero.Sync.Storage.SYNC_STATE_TO_UPLOAD;
}
for (var itemID in updatedStates) {
Zotero.Sync.Storage.setSyncState(itemID, updatedStates[itemID]);
changed = true;
}
if (!changed) {
Zotero.debug("No synced files have changed locally");
}
let msg = "Checked " + numItems + " files in ";
if (libraryID !== false) {
msg += "library " + libraryID + " in ";
}
msg += (new Date() - t) + "ms";
Zotero.debug(msg);
throw new Task.Result(changed);
}
Components.utils.import("resource://gre/modules/osfile.jsm");
let checkItems = function () {