logging skipped files after conversion

This commit is contained in:
Daniel Sommer 2017-03-28 16:08:01 +02:00
parent 71918aedd5
commit 7ef69b163c
3 changed files with 24 additions and 7 deletions

View file

@ -69,8 +69,21 @@ function sort(input, output, options) {
concurrency: commander.concurrency || os.cpus().length, concurrency: commander.concurrency || os.cpus().length,
bitrate: options.bitrate || 320, bitrate: options.bitrate || 320,
format: options.format || '.flac' format: options.format || '.flac'
}, function (err, time) { }, function (err, skipped, time) {
if (!skipped || skipped.length === 0) {
cli.exit(err, time); 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);
});
}
}); });
} }

View file

@ -27,20 +27,24 @@ function batchSort(config, callback) {
}, },
// process each file // process each file
function (files, bar, waterfallCallback) { function (files, bar, waterfallCallback) {
let skipped = [];
timestamp = process.hrtime(); timestamp = process.hrtime();
async.eachLimit(files, config.concurrency, function (file, eachCallback) { async.eachLimit(files, config.concurrency, function (file, eachCallback) {
moveFile(file, config, function (err) { moveFile(file, config, function (err, moved) {
bar.tick(); bar.tick();
if (err) { if (err) {
return eachCallback(err); return eachCallback(err);
} }
if (!moved) {
skipped.push(file);
}
eachCallback(); eachCallback();
}) })
}, function (err, result) { }, function (err, result) {
if (err) { if (err) {
return waterfallCallback(err); return waterfallCallback(err);
} }
waterfallCallback(null, timestamp); waterfallCallback(null, skipped, timestamp);
}); });
} }
], callback); ], callback);
@ -71,12 +75,12 @@ function moveFile(source, config, callback) {
fse.move(source, target, function (err) { fse.move(source, target, function (err) {
if (err) { if (err) {
if (err.code === 'EEXIST') { if (err.code === 'EEXIST') {
console.log('file already exists, skipping ...'); return waterfallCallback();
} else { } else {
return waterfallCallback(err); return waterfallCallback(err);
} }
} }
waterfallCallback(); waterfallCallback(null, true);
}); });
} }
], callback); ], callback);

View file

@ -1,6 +1,6 @@
{ {
"name": "badger-am", "name": "badger-am",
"version": "0.6.0", "version": "0.6.1",
"license": "MIT", "license": "MIT",
"description": "audio manager", "description": "audio manager",
"author": "Daniel Sommer <daniel.sommer@velvettear.de>", "author": "Daniel Sommer <daniel.sommer@velvettear.de>",