www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit ac5071e94ee6aac4660f21badc0336bf59d9b759
parent 083bdd4753f183dd28ca5588b28ced195b94933e
Author: Dan Stillman <dstillman@zotero.org>
Date:   Wed, 17 Sep 2008 19:35:37 +0000

- Handle URL encoding of 'href' value in PROPFIND response when purging files
- Fix a scoping issue that could prevent some property files from being purged
- Properly handle systems with millisecond-level file mod time granularity (clearing of storage sync history is required)
- Fix issue that might have erroneously removed property files


Diffstat:
Mchrome/content/zotero/xpcom/data/item.js | 2+-
Mchrome/content/zotero/xpcom/storage.js | 24+++++++++++++++++-------
2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js @@ -2569,7 +2569,7 @@ Zotero.Item.prototype.__defineGetter__('attachmentModificationTime', function () return undefined; } - return file.lastModifiedTime / 1000; + return Math.round(file.lastModifiedTime / 1000); }); diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js @@ -824,6 +824,8 @@ Zotero.Sync.Storage = new function () { var lastSyncDate = new Date(Zotero.Sync.Server.lastLocalSyncTime * 1000); Zotero.Utilities.HTTP.WebDAV.doProp("PROPFIND", uri, xmlstr, function (req) { + var funcName = "Zotero.Sync.Storage.purgeOrphanedStorageFiles()"; + // Strip XML declaration and convert to E4X var xml = new XML(req.responseText.replace(/<\?xml.*\?>/, '')); @@ -831,22 +833,30 @@ Zotero.Sync.Storage = new function () { for each(var response in xml.D::response) { var href = response.D::href.toString(); - // Convert absolute to relative + // Absolute if (href.match(/^https?:\/\//)) { var ios = Components.classes["@mozilla.org/network/io-service;1"]. getService(Components.interfaces.nsIIOService); - href = ios.newURI(href, null, null).path; + var href = ios.newURI(href, null, null); + if (href.path != path) { + _error("DAV:href '" + href.path + + "' does not match path in " + funcName); + } + href = href.path; } // Skip root URI - if (href == path) { + // + // Try URL-encoded as well, in case there's a '~' or similar + // character in the URL and the server (e.g., Sakai) is + // encoding the value + if (href == path || decodeURIComponent(href) == path) { continue; } var matches = href.match(/[^\/]+$/); if (!matches) { - _error("Unexpected href '" + href - + "' in Zotero.Sync.Storage.purgeOrphanedStorageFiles()") + _error("Unexpected href '" + href + "' in " + funcName) } var file = matches[0]; @@ -859,7 +869,7 @@ Zotero.Sync.Storage = new function () { continue; } - var key = file.replace(/\.zip/, ''); + var key = file.replace(/\.(zip|prop)$/, ''); var item = Zotero.Items.getByKey(key); if (item) { Zotero.debug("Skipping existing file " + file); @@ -1364,7 +1374,7 @@ Zotero.Sync.Storage = new function () { let last = (i == files.length - 1); let fileName = files[i]; - var deleteURI = Zotero.Sync.Storage.rootURI; + let deleteURI = Zotero.Sync.Storage.rootURI; // This should never happen, but let's be safe if (!deleteURI.spec.match(/\/$/)) { callback(deleted);