commit 74c679e6d24781b6700c2072957568e3a051d09f
parent ccc18dd41e8386f2623b4b56cbd7372ca9d27605
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 20 Aug 2013 12:54:36 -0400
Remove non-OS.File storage code, now that last mtime works on Win in Fx24
Diffstat:
1 file changed, 0 insertions(+), 127 deletions(-)
diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js
@@ -807,133 +807,6 @@ Zotero.Sync.Storage = new function () {
var numItems = items.length;
var updatedStates = {};
- // On Windows, OS.File returns the access time instead of the
- // modification time until Firefox 25
- // (https://bugzilla.mozilla.org/show_bug.cgi?id=899436),
- // so use the old code
- if (Zotero.isWin && Zotero.platformMajorVersion < 25) {
- 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[id]) {
- Zotero.debug("Storage mod time (" + row.storageModTime + ") "
- + "hasn't changed for item " + lk);
- continue;
- }
-
- Zotero.debug("Marking attachment " + lk + " for download");
- 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);
- }
-
let checkItems = function () {
if (!items.length) return Q();