logging skipped files after conversion
This commit is contained in:
parent
71918aedd5
commit
7ef69b163c
3 changed files with 24 additions and 7 deletions
17
badger-am.js
17
badger-am.js
|
@ -69,8 +69,21 @@ function sort(input, output, options) {
|
|||
concurrency: commander.concurrency || os.cpus().length,
|
||||
bitrate: options.bitrate || 320,
|
||||
format: options.format || '.flac'
|
||||
}, function (err, time) {
|
||||
cli.exit(err, time);
|
||||
}, function (err, skipped, time) {
|
||||
if (!skipped || skipped.length === 0) {
|
||||
cli.exit(err, time);
|
||||
} else {
|
||||
console.log(skipped.length + ' files were skipped after ' + util.getTimeDiff(time) + ' seconds');
|
||||
cli.askForConfirmation('list files now?', ['yes', 'y'], function (canceled) {
|
||||
if (canceled) {
|
||||
cli.exit(err, time);
|
||||
}
|
||||
skipped.forEach(function (file) {
|
||||
console.log(file);
|
||||
});
|
||||
cli.exit(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
12
lib/util.js
12
lib/util.js
|
@ -27,20 +27,24 @@ function batchSort(config, callback) {
|
|||
},
|
||||
// process each file
|
||||
function (files, bar, waterfallCallback) {
|
||||
let skipped = [];
|
||||
timestamp = process.hrtime();
|
||||
async.eachLimit(files, config.concurrency, function (file, eachCallback) {
|
||||
moveFile(file, config, function (err) {
|
||||
moveFile(file, config, function (err, moved) {
|
||||
bar.tick();
|
||||
if (err) {
|
||||
return eachCallback(err);
|
||||
}
|
||||
if (!moved) {
|
||||
skipped.push(file);
|
||||
}
|
||||
eachCallback();
|
||||
})
|
||||
}, function (err, result) {
|
||||
if (err) {
|
||||
return waterfallCallback(err);
|
||||
}
|
||||
waterfallCallback(null, timestamp);
|
||||
waterfallCallback(null, skipped, timestamp);
|
||||
});
|
||||
}
|
||||
], callback);
|
||||
|
@ -71,12 +75,12 @@ function moveFile(source, config, callback) {
|
|||
fse.move(source, target, function (err) {
|
||||
if (err) {
|
||||
if (err.code === 'EEXIST') {
|
||||
console.log('file already exists, skipping ...');
|
||||
return waterfallCallback();
|
||||
} else {
|
||||
return waterfallCallback(err);
|
||||
}
|
||||
}
|
||||
waterfallCallback();
|
||||
waterfallCallback(null, true);
|
||||
});
|
||||
}
|
||||
], callback);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "badger-am",
|
||||
"version": "0.6.0",
|
||||
"version": "0.6.1",
|
||||
"license": "MIT",
|
||||
"description": "audio manager",
|
||||
"author": "Daniel Sommer <daniel.sommer@velvettear.de>",
|
||||
|
|
Loading…
Reference in a new issue