From e0cf6098fb73833f5db85294d95875a62163f116 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Wed, 19 Oct 2011 21:46:28 +0200 Subject: [PATCH] fixing issues with bad import uploads, fixed #186 --- node/handler/ImportHandler.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/node/handler/ImportHandler.js b/node/handler/ImportHandler.js index 8936e488..a1ddf992 100644 --- a/node/handler/ImportHandler.js +++ b/node/handler/ImportHandler.js @@ -61,10 +61,19 @@ exports.doImport = function(req, res, padId) form.parse(req, function(err, fields, files) { - //save the path of the uploaded file - srcFile = files.file.path; - - callback(err); + //the upload failed, stop at this point + if(err || files.file === undefined) + { + console.warn("Uploading Error: " + err.stack); + callback("uploadFailed"); + } + //everything ok, continue + else + { + //save the path of the uploaded file + srcFile = files.file.path; + callback(); + } }); }, @@ -157,6 +166,13 @@ exports.doImport = function(req, res, padId) } ], function(err) { + //the upload failed, there is nothing we can do, send a 500 + if(err == "uploadFailed") + { + res.send(500); + return; + } + if(err) throw err; //close the connection