Skip to content

The swiss army knife of lossless video/audio editing

improve startup check

Mikael Finstad251106dd6d05
diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx
index 79e90e21..cf8bb60a 100644
--- a/src/renderer/src/App.tsx
+++ b/src/renderer/src/App.tsx
@@ -2406,8 +2406,8 @@ function App() {
}, []);
useEffect(() => {
- runStartupCheck({ customFfPath });
- }, [customFfPath]);
+ runStartupCheck({ onError: ({ title, message }) => setGenericError({ title, err: message }) });
+ }, [customFfPath, setGenericError]);
const haveBoundAlt = useMemo(() => keyBindings.some(({ keys }) => keys.split('+').includes('alt')), [keyBindings]);
diff --git a/src/renderer/src/mifi.ts b/src/renderer/src/mifi.ts
index 554dded1..c5e29bef 100644
--- a/src/renderer/src/mifi.ts
+++ b/src/renderer/src/mifi.ts
@@ -1,9 +1,10 @@
import ky from 'ky';
+import i18n from 'i18next';
import { runFfmpegStartupCheck, getFfmpegPath } from './ffmpeg';
import isDev from './isDev';
import { openSendReportDialog } from './reporting';
-import getSwal from './swal';
+import { isMasBuild } from './util';
export async function loadMifiLink() {
@@ -17,30 +18,34 @@ export async function loadMifiLink() {
}
}
-export async function runStartupCheck({ customFfPath }: { customFfPath: string | undefined }) {
+export async function runStartupCheck({ onError }: { onError: (error: { title: string, message: string }) => void }) {
try {
await runFfmpegStartupCheck();
} catch (err) {
- if (err instanceof Error) {
- if (!customFfPath && 'code' in err && typeof err.code === 'string' && ['EPERM', 'EACCES'].includes(err.code)) {
- getSwal().Swal.fire({
- 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`,
+ if (err instanceof Error && !isMasBuild) {
+ if ('code' in err && err.code === 'ENOENT') {
+ onError({
+ title: i18n.t('Fatal: FFmpeg executable not found'),
+ message: `${i18n.t('Make sure that the FFmpeg executable exists:')}\n\n${getFfmpegPath()}`,
});
return;
}
- if (customFfPath && 'code' in err && err.code === 'ENOENT') {
- getSwal().Swal.fire({
- icon: 'error',
- title: 'Fatal: ffmpeg not found',
- text: `Make sure that ffmpeg executable exists: ${getFfmpegPath()}`,
+ if ('code' in err && typeof err.code === 'string' && ['EPERM', 'EACCES', 'ENOENT'].includes(err.code)) {
+ onError({
+ title: i18n.t('Fatal: FFmpeg not accessible'),
+ message: [
+ i18n.t('Error code: {{errorCode}}. This could mean that anti-virus or something else is blocking the execution of FFmpeg. Make sure the following file exists and is executable:', { errorCode: err.code }),
+ '',
+ getFfmpegPath(),
+ '',
+ i18n.t('Read more: {{url}}', { url: 'https://github.com/mifi/lossless-cut/issues/1114' }),
+ ].join('\n'),
});
return;
}
}
- openSendReportDialog({ message: 'FFmpeg is non-functional', err });
+ openSendReportDialog({ message: i18n.t('FFmpeg is non-functional'), err });
}
}