Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 521259 - Trying to import a non-archive sends the wrong result
  • Loading branch information
mrennie committed Aug 22, 2017
1 parent 1c8459d commit 7dcc54d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions modules/orionode/lib/xfer.js
Expand Up @@ -118,8 +118,14 @@ function postImportXferTo(req, res, file) {
var lengthStr = req.get("X-Xfer-Content-Length") || req.get("Content-Length");
if (lengthStr) length = Number(lengthStr);
} else {
upload(request(sourceURL));
return;
var rerr,
newreq = request(sourceURL, {}, function(err, res) {
rerr = err;
})
if(rerr) {
return writeError(400, res, rerr.message);
}
return upload(newreq);
}
if (req.get("Content-Type") === "application/octet-stream") {
upload(req);
Expand Down Expand Up @@ -179,7 +185,9 @@ function completeTransfer(req, res, tempFile, file, fileName, xferOptions, shoul
lazyEntries: true,
validateEntrySizes: true
}, function(err, zipfile) {
if (err) throw err;
if (err) {
return writeError(400, res, err.message);
}
zipfile.readEntry();
zipfile.on("close", function() {
fs.unlink(tempFile, function(exp){});
Expand All @@ -195,7 +203,7 @@ function completeTransfer(req, res, tempFile, file, fileName, xferOptions, shoul
zipfile.on("error",function(err){
if (res) {
return writeError(400, res, "Failed during file unzip: " + err.message);
}
}
});
zipfile.on("entry", function(entry) {
var entryName = entry.fileName;
Expand Down

0 comments on commit 7dcc54d

Please sign in to comment.