From 71e01f8485e09b8811cde168ea8b3d10ee01eef9 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Wed, 25 Aug 2021 16:00:09 +0700 Subject: [PATCH] Add check for output file length on windows #745 --- src/App.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index ed3d51b0..c667e6d1 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -954,8 +954,16 @@ const App = memo(() => { pathSep, ':', // https://github.com/mifi/lossless-cut/issues/631 ]; - const sameAsInputPath = pathNormalize(pathJoin(outputDir, fileName)) === pathNormalize(filePath); - return fileName.length > 0 && !invalidChars.some((c) => fileName.includes(c)) && !sameAsInputPath; + const outPath = pathNormalize(pathJoin(outputDir, fileName)); + const sameAsInputPath = outPath === pathNormalize(filePath); + const windowsMaxPathLength = 259; + const shouldCheckPathLength = isWindows || isDev; + return ( + fileName.length > 0 + && !invalidChars.some((c) => fileName.includes(c)) + && !sameAsInputPath + && (!shouldCheckPathLength || outPath.length < windowsMaxPathLength) + ); }), [outputDir, filePath]); const openSendReportDialogWithState = useCallback(async (err) => {