From 36f34aff6042b8edaf97de998954fbb08e135752 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Mon, 25 Jul 2022 17:59:17 +0800 Subject: [PATCH] improve error message on startup #1114 --- src/App.jsx | 20 +++++++++++++++++++- src/util.js | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index a18acb91..0172dc3d 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -56,6 +56,7 @@ import { extractStreams, runStartupCheck, setCustomFfPath as ffmpegSetCustomFfPath, isIphoneHevc, tryMapChaptersToEdl, blackDetect, getDuration, getTimecodeFromStreams, createChaptersFromSegments, extractSubtitleTrack, + getFfmpegPath, } from './ffmpeg'; import { shouldCopyStreamByDefault, getAudioStreams, getRealVideoStreams, defaultProcessedCodecTypes, isAudioDefinitelyNotSupported, doesPlayerSupportFile } from './util/streams'; import { exportEdlFile, readEdlFile, saveLlcProject, loadLlcProject, askForEdlImport } from './edlStore'; @@ -2272,7 +2273,24 @@ const App = memo(() => { const haveCustomFfPath = !!customFfPath; useEffect(() => { - if (!haveCustomFfPath) runStartupCheck().catch((err) => handleError('LosslessCut is installation is broken', err)); + if (!haveCustomFfPath) { + (async () => { + try { + await runStartupCheck(); + } catch (err) { + if (['EPERM', 'EACCES'].includes(err.code)) { + toast.fire({ + timer: 30000, + icon: 'error', + title: 'Fatal: ffmpeg not accessible', + text: `Got ${err.code}. This probably means that anti-virus is blocking execution of ffmpeg. Please make sure the following file exists and is executable:\n\n${getFfmpegPath()}\n\nSee this issue: https://github.com/mifi/lossless-cut/issues/1114`, + }); + return; + } + handleError('Fatal: ffmpeg non-functional', err); + } + })(); + } }, [haveCustomFfPath]); useEffect(() => { diff --git a/src/util.js b/src/util.js index 96d32522..63379bf2 100644 --- a/src/util.js +++ b/src/util.js @@ -116,7 +116,7 @@ export function handleError(arg1, arg2) { toast.fire({ icon: 'error', title: msg || i18n.t('An error has occurred.'), - text: errorMsg ? errorMsg.substr(0, 300) : undefined, + text: errorMsg ? errorMsg.substring(0, 300) : undefined, }); }