From a1a2e0f46c590c7c05358160e45d2d25e82f5c97 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Tue, 8 Nov 2016 22:14:15 +0100 Subject: [PATCH] Bug fixes Fix null error if unknown filetype. Handle ENOENT: Windows will throw error with code ENOENT if format detection fails. --- src/ffmpeg.js | 2 +- src/renderer.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ffmpeg.js b/src/ffmpeg.js index 844546c3..f75daccb 100644 --- a/src/ffmpeg.js +++ b/src/ffmpeg.js @@ -78,7 +78,7 @@ function getFormat(filePath) { return readChunk(filePath, 0, 262) .then((bytes) => { const ft = fileType(bytes); - if (_.includes(formats, ft.ext)) return ft.ext; + if (_.includes(formats, (ft || {}).ext)) return ft.ext; return formats[0] || undefined; }); }); diff --git a/src/renderer.jsx b/src/renderer.jsx index b319af0b..f8b31022 100644 --- a/src/renderer.jsx +++ b/src/renderer.jsx @@ -78,7 +78,7 @@ class App extends React.Component { return this.setState({ filePath, fileFormat }); }) .catch((err) => { - if (err.code === 1) { + if (err.code === 1 || err.code === 'ENOENT') { alert('Unsupported file'); return; }