Fix potential cause of "Downloaded file not found in Zotero.Sync.Storage.processDownload()"
This commit is contained in:
parent
38459c5d0e
commit
3941dd911a
1 changed files with 5 additions and 8 deletions
|
@ -189,13 +189,10 @@ Zotero.Sync.Storage.Session.ZFS.prototype.downloadFile = function (request) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
destFile.append(item.key + '.tmp');
|
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(
|
var listener = new Zotero.Sync.Storage.StreamListener(
|
||||||
{
|
{
|
||||||
|
@ -255,8 +252,8 @@ Zotero.Sync.Storage.Session.ZFS.prototype.downloadFile = function (request) {
|
||||||
var wbp = Components
|
var wbp = Components
|
||||||
.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
|
.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
|
||||||
.createInstance(nsIWBP);
|
.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.progressListener = listener;
|
||||||
wbp.saveURI(uri, null, null, null, null, destFile);
|
wbp.saveURI(uri, null, null, null, null, destFile);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue