From 5ded061a5476ed8d44bf040411ba51ac088e8ddd Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Sun, 25 Jun 2017 10:31:54 -0700 Subject: [PATCH] Make music scanning much more forgiving --- main/index.js | 4 ++-- main/library.js | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/main/index.js b/main/index.js index 871f1a6..74e996c 100644 --- a/main/index.js +++ b/main/index.js @@ -106,7 +106,7 @@ app.on('ready', () => { state.currentIndex = newIndex queue(null, newIndex) if (state.playing) { broadcast('play') } - } else { console.warn('Can go back, empty trackOrder array') } + } else { console.warn('Can\'t go back, empty trackOrder array') } } ipcMain.on('prev', prev) @@ -117,7 +117,7 @@ app.on('ready', () => { state.currentIndex = newIndex queue(null, newIndex) if (state.playing) { broadcast('play') } - } else { console.warn('Can go forward, empty trackOrder array') } + } else { console.warn('Can\'t go forward, empty trackOrder array') } } ipcMain.on('next', next) diff --git a/main/library.js b/main/library.js index 8787879..fa70a2d 100644 --- a/main/library.js +++ b/main/library.js @@ -31,6 +31,7 @@ function isValidFile (data, enc, cb) { function concatTrackDict (obj) { function writeTrackDict (data, enc, cb) { + console.log(`Scanning ${data.filepath}`) parseMetadata(data, handleMeta) function handleMeta (err, meta) { @@ -46,14 +47,19 @@ function parseMetadata (data, cb) { var { filepath } = data var readableStream = fs.createReadStream(filepath) mm(readableStream, { duration: true }, (err, meta) => { - readableStream.close() + readableStream.destroy() if (err) { switch (err.message) { case 'Could not find metadata header': console.warn(err.message += ` (file: ${filepath})`) break + case 'expected frame header but was not found': + console.warn(err.message += ` (file: ${filepath})`) + break default: - return cb(err) + // Ignore errors + console.warn(err.message += ` (file: ${filepath})`) + return cb(null) } }