fixing issues with bad import uploads, fixed #186

This commit is contained in:
Peter 'Pita' Martischka 2011-10-19 21:46:28 +02:00
parent fb158d2eb8
commit e0cf6098fb

View file

@ -61,10 +61,19 @@ exports.doImport = function(req, res, padId)
form.parse(req, function(err, fields, files) form.parse(req, function(err, fields, files)
{ {
//save the path of the uploaded file //the upload failed, stop at this point
srcFile = files.file.path; if(err || files.file === undefined)
{
callback(err); 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) ], 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; if(err) throw err;
//close the connection //close the connection