Fix remote file saving

5f8b56ef8 was so many different kinds of broken
This commit is contained in:
Dan Stillman 2015-01-31 15:22:02 -05:00
parent deb77cdb08
commit bcacb79489
5 changed files with 24 additions and 21 deletions

View file

@ -392,7 +392,7 @@ Zotero_Preferences.Search = {
wbp.progressListener = progressListener;
Zotero.debug("Saving " + uri.spec + " to " + fileURL.spec);
Zotero.Utilities.Internal.saveURI(wbp, nsIURL, file);
Zotero.Utilities.Internal.saveURI(wbp, uri, fileURL);
},

View file

@ -672,7 +672,7 @@ var wpdCommon = {
// has the url the same filetype like the file extension?
//save file to target
Zotero.Utilities.Internal.saveURI(wbp, nsIURL, file);
Zotero.Utilities.Internal.saveURI(wbp, obj_URI, obj_TargetFile);
return true;

View file

@ -963,7 +963,7 @@ Zotero.Sync.Storage.WebDAV = (function () {
.createInstance(nsIWBP);
wbp.persistFlags = nsIWBP.PERSIST_FLAGS_BYPASS_CACHE;
wbp.progressListener = listener;
Zotero.Utilities.Internal.saveURI(wbp, nsIURL, file);
Zotero.Utilities.Internal.saveURI(wbp, uri, destFile);
return deferred.promise;
});

View file

@ -944,7 +944,7 @@ Zotero.Sync.Storage.ZFS = (function () {
.createInstance(nsIWBP);
wbp.persistFlags = nsIWBP.PERSIST_FLAGS_BYPASS_CACHE;
wbp.progressListener = listener;
Zotero.Utilities.Internal.saveURI(wbp, nsIURL, file);
Zotero.Utilities.Internal.saveURI(wbp, uri, destFile);
return deferred.promise;
});

View file

@ -266,6 +266,25 @@ Zotero.Utilities.Internal = {
}
},
/**
* saveURI wrapper function
* @param {nsIWebBrowserPersist} nsIWebBrowserPersist
* @param {nsIURI} source URL
* @param {nsISupports} target file
*/
saveURI: function (wbp, source, target) {
// Firefox 35 and below
try {
wbp.saveURI(source, null, null, null, null, target, null);
}
// Firefox 36+ needs one more parameter
catch (e if e.name === "NS_ERROR_XPC_NOT_ENOUGH_ARGS") {
wbp.saveURI(source, null, null, null, null, null, target, null);
}
},
/**
* Launch a process
* @param {nsIFile} cmd Path to command to launch
@ -469,21 +488,5 @@ Zotero.Utilities.Internal.Base64 = {
}
return string;
},
/**
* saveURI wrapper function
* @param {nsIWebBrowserPersist} nsIWebBrowserPersist
* @param {nsIURI} source URL
* @param {nsISupports} target file
*/
saveURI: function (wbp, source, target) {
// Firefox 35 and below
try {
wbp.saveURI(source, null, null, null, null, target, null);
}
// Firefox 36+ needs one more parameter
catch (e if e.name === "NS_ERROR_XPC_NOT_ENOUGH_ARGS") {
wbp.saveURI(source, null, null, null, null, null, target, null);
}
}
}
}