fx-compat: Fix Zotero.File.download()
This commit is contained in:
parent
8f7a160ba1
commit
dfff86df72
2 changed files with 10 additions and 7 deletions
|
@ -474,7 +474,6 @@ Zotero.File = new function(){
|
||||||
// NOTE: This noop callback is required, do not remove.
|
// NOTE: This noop callback is required, do not remove.
|
||||||
},
|
},
|
||||||
onStopRequest(request, status) {
|
onStopRequest(request, status) {
|
||||||
const responseStatus = 'responseStatus' in request ? request.responseStatus : null;
|
|
||||||
pipe.outputStream.close();
|
pipe.outputStream.close();
|
||||||
|
|
||||||
if (!Components.isSuccessCode(status)) {
|
if (!Components.isSuccessCode(status)) {
|
||||||
|
@ -490,11 +489,14 @@ Zotero.File = new function(){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isHTTP && responseStatus != 200) {
|
if (isHTTP) {
|
||||||
let msg = `Download failed with response code ${responseStatus}`;
|
let statusCode = request.QueryInterface(Ci.nsIHttpChannel).responseStatus;
|
||||||
Zotero.logError(msg);
|
if (statusCode != 200) {
|
||||||
deferred.reject(new Error(msg));
|
let msg = `Download failed with response code ${responseStatus}`;
|
||||||
return;
|
Zotero.logError(msg);
|
||||||
|
deferred.reject(new Error(msg));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -493,7 +493,8 @@ describe("Zotero.File", function () {
|
||||||
|
|
||||||
it("should concurrently download three large files", async function () {
|
it("should concurrently download three large files", async function () {
|
||||||
const url = `${baseURL}/file1.txt`;
|
const url = `${baseURL}/file1.txt`;
|
||||||
|
|
||||||
|
var { ConcurrentCaller } = ChromeUtils.import("resource://zotero/concurrentCaller.js");
|
||||||
var caller = new ConcurrentCaller({
|
var caller = new ConcurrentCaller({
|
||||||
numConcurrent: 3,
|
numConcurrent: 3,
|
||||||
Promise: Zotero.Promise,
|
Promise: Zotero.Promise,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue