diff --git a/src/App.jsx b/src/App.jsx index d890e908..e2a317cb 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -59,7 +59,7 @@ import { checkDirWriteAccess, dirExists, openDirToast, isMasBuild, isStoreBuild, dragPreventer, doesPlayerSupportFile, isDurationValid, isWindows, filenamify, getOutFileExtension, generateSegFileName, defaultOutSegTemplate, hasDuplicates, havePermissionToReadFile, isMac, resolvePathIfNeeded, pathExists, html5ifiedPrefix, html5dummySuffix, findExistingHtml5FriendlyFile, - deleteFiles, getHtml5ifiedPath, isStreamThumbnail, getAudioStreams, getVideoStreams, + deleteFiles, getHtml5ifiedPath, isStreamThumbnail, getAudioStreams, getVideoStreams, isOutOfSpaceError, } from './util'; import { formatDuration } from './util/duration'; import { adjustRate } from './util/rate-calculator'; @@ -665,6 +665,10 @@ const App = memo(() => { await ffmpegMergeFiles({ paths, outPath, outDir, allStreams, ffmpegExperimental, onProgress: setCutProgress, preserveMovData, movFastStart, preserveMetadataOnMerge, chapters }); openDirToast({ icon: 'success', dirPath: outDir, text: i18n.t('Files merged!') }); } catch (err) { + if (isOutOfSpaceError(err)) { + showDiskFull(); + return; + } errorToast(i18n.t('Failed to merge files. Make sure they are all of the exact same codecs')); console.error('Failed to merge files', err); } finally { @@ -1182,8 +1186,7 @@ const App = memo(() => { console.error('stderr:', err.stderr); if (err.exitCode === 1 || err.code === 'ENOENT') { - // A bit hacky but it works, unless someone has a file called "No space left on device" ( ͡° ͜ʖ ͡°) - if (typeof err.stderr === 'string' && err.stderr.includes('No space left on device')) { + if (isOutOfSpaceError(err)) { showDiskFull(); return; } diff --git a/src/util.js b/src/util.js index 24474eec..a5cce02b 100644 --- a/src/util.js +++ b/src/util.js @@ -287,3 +287,9 @@ export async function deleteFiles({ toDelete, paths: { previewFilePath, filePath export const deleteDispositionValue = 'llc_disposition_remove'; export const mirrorTransform = 'matrix(-1, 0, 0, 1, 0, 0)'; + +// A bit hacky but it works, unless someone has a file called "No space left on device" ( ͡° ͜ʖ ͡°) +export const isOutOfSpaceError = (err) => ( + err && (err.exitCode === 1 || err.code === 'ENOENT') + && typeof err.stderr === 'string' && err.stderr.includes('No space left on device') +);