From 7ef69b163c25b7c47a4de1cae3d60a8c78148aa2 Mon Sep 17 00:00:00 2001 From: velvettear Date: Tue, 28 Mar 2017 16:08:01 +0200 Subject: [PATCH] logging skipped files after conversion --- badger-am.js | 17 +++++++++++++++-- lib/util.js | 12 ++++++++---- package.json | 2 +- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/badger-am.js b/badger-am.js index 1b70f97..f0fe36c 100755 --- a/badger-am.js +++ b/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); + }); + } }); } diff --git a/lib/util.js b/lib/util.js index 9daaa2e..947667f 100644 --- a/lib/util.js +++ b/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); diff --git a/package.json b/package.json index 2544e37..74125c6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "badger-am", - "version": "0.6.0", + "version": "0.6.1", "license": "MIT", "description": "audio manager", "author": "Daniel Sommer ",