Skip to content

Commit bf33103

Browse files
committed
remove directory on error
1 parent 6113049 commit bf33103

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/load.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ var Promise = require('bluebird'),
88
Logger = require('./log.js'),
99
defaults = require('./defaults.js');
1010

11-
var encoding = 'binary';
12-
1311
/** @constructor */
1412
var Loader = function (data) {
1513
var options = _.clone(data),
14+
encoding = 'binary',
1615
loadedFiles = {},
1716
staticFullPaths,
1817
logger;
@@ -315,6 +314,10 @@ var Loader = function (data) {
315314
return p;
316315
}
317316

317+
function errorCleanup() {
318+
return fs.removeAsync(options.path);
319+
}
320+
318321
return {
319322
scrape: function (callback) {
320323
if (fs.existsSync(options.path)) {
@@ -326,7 +329,10 @@ var Loader = function (data) {
326329
return callback(null, res)
327330
})
328331
.catch(function (e) {
329-
return callback(e, null)
332+
return errorCleanup()
333+
.then(function() {
334+
return callback(e, null)
335+
});
330336
})
331337
}
332338
}

0 commit comments

Comments
 (0)