fixing issues with bad import uploads, fixed #186

pull/191/head
Peter 'Pita' Martischka 2011-10-19 21:46:28 +02:00
parent fb158d2eb8
commit e0cf6098fb
1 changed files with 20 additions and 4 deletions

View File

@ -60,11 +60,20 @@ exports.doImport = function(req, res, padId)
form.uploadDir = tempDirectory;
form.parse(req, function(err, fields, files)
{
//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(err);
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