Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update local.js #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 deletions lib/transport/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,33 @@ module.exports = function(opts) {

},
delete: function(req, res, callback) {
var options = this.options;
var fileName = '';
if (req.url.slice(0, options.uploadUrl.length) === options.uploadUrl) {
fileName = path.basename(decodeURIComponent(req.url));
if (fileName[0] !== '.') {
fs.unlink(options.uploadDir + '/' + fileName, function(ex) {
Object.keys(options.imageVersions).forEach(function(version) {
// TODO - Missing callback
fs.unlink(options.uploadDir + '/' + version + '/' + fileName);
});
callback(null, {
success: true
});
});
return;
var options = this.options;
var fileName = '';
if (req.url.slice(0, options.uploadUrl.length) === options.uploadUrl) {
fileName = path.basename(decodeURIComponent(req.url));
if (fileName[0] !== '.') {
fs.unlink(options.uploadDir + '/' + fileName, function (ex) {
// Done - Added error passing here
if (ex) {
callback({ error: ex, failure: true }, null);
}
Object.keys(options.imageVersions).forEach(function (version) {
// Done - Added callback here
fs.unlink(options.uploadDir + '/' + version + '/' + fileName, function (ex) {
//Done - Added error passing here
if (ex) {
callback({ error: ex, failure: true }, null);
}
});
});
callback(null, {
success: true
});
});
return;
}
callback(new Error('File name invalid:' + fileName), null);
}
callback(new Error('File name invalid:' + fileName), null);
}
};

Expand Down