From 3941dd911a1b7ec7e3cd66a7e2abf171faf53665 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 27 Sep 2009 07:40:39 +0000 Subject: [PATCH] Fix potential cause of "Downloaded file not found in Zotero.Sync.Storage.processDownload()" --- chrome/content/zotero/xpcom/storage/zfs.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/chrome/content/zotero/xpcom/storage/zfs.js b/chrome/content/zotero/xpcom/storage/zfs.js index 4f4ddaf4c3..3ef9013196 100644 --- a/chrome/content/zotero/xpcom/storage/zfs.js +++ b/chrome/content/zotero/xpcom/storage/zfs.js @@ -189,13 +189,10 @@ Zotero.Sync.Storage.Session.ZFS.prototype.downloadFile = function (request) { } else { destFile.append(item.key + '.tmp'); - if (destFile.exists()) { - destFile.remove(false); - } - } - if (destFile.exists()) { - destFile.remove(false); } + // saveURI() below appears not to create empty files for Content-Length: 0, + // so we create one here just in case + destFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644); var listener = new Zotero.Sync.Storage.StreamListener( { @@ -255,8 +252,8 @@ Zotero.Sync.Storage.Session.ZFS.prototype.downloadFile = function (request) { var wbp = Components .classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"] .createInstance(nsIWBP); - wbp.persistFlags = nsIWBP.PERSIST_FLAGS_BYPASS_CACHE; - + wbp.persistFlags = nsIWBP.PERSIST_FLAGS_BYPASS_CACHE + | nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES; wbp.progressListener = listener; wbp.saveURI(uri, null, null, null, null, destFile); }