From 08aff31351e4e2771a1dd04bf30c1401886f021e Mon Sep 17 00:00:00 2001 From: Azeru Date: Sat, 11 Apr 2026 17:27:52 +0100 Subject: [PATCH] fix(windows): normalize export save path and relax early decode end --- electron/ipc/handlers.ts | 13 +++++++++---- src/lib/exporter/streamingDecoder.ts | 16 +++++++++++++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/electron/ipc/handlers.ts b/electron/ipc/handlers.ts index 4cb4875..9a5a6c0 100644 --- a/electron/ipc/handlers.ts +++ b/electron/ipc/handlers.ts @@ -638,7 +638,6 @@ export function registerIpcHandlers( return null; } }); - ipcMain.handle("save-exported-video", async (_, videoData: ArrayBuffer, fileName: string) => { try { // Determine file type from extension @@ -664,11 +663,18 @@ export function registerIpcHandlers( }; } - await fs.writeFile(result.filePath, Buffer.from(videoData)); + // --- FIX: Normalize the path for Windows compatibility --- + const normalizedPath = path.normalize(result.filePath); + + // Ensure the parent directory exists (Windows may fail if the folder is missing) + await fs.mkdir(path.dirname(normalizedPath), { recursive: true }); + // --- END FIX --- + + await fs.writeFile(normalizedPath, Buffer.from(videoData)); return { success: true, - path: result.filePath, + path: normalizedPath, message: "Video exported successfully", }; } catch (error) { @@ -680,7 +686,6 @@ export function registerIpcHandlers( }; } }); - ipcMain.handle("open-video-file-picker", async () => { try { const result = await dialog.showOpenDialog({ diff --git a/src/lib/exporter/streamingDecoder.ts b/src/lib/exporter/streamingDecoder.ts index ee67576..bed103b 100644 --- a/src/lib/exporter/streamingDecoder.ts +++ b/src/lib/exporter/streamingDecoder.ts @@ -492,6 +492,8 @@ export class StreamingVideoDecoder { this.decoder = null; const requiredEndSec = segments.length > 0 ? segments[segments.length - 1].endSec : 0; + const isWindows = typeof navigator !== "undefined" && /Windows/.test(navigator.userAgent); + if ( shouldFailDecodeEndedEarly({ cancelled: this.cancelled, @@ -502,9 +504,17 @@ export class StreamingVideoDecoder { ) { const decodedAtLabel = lastDecodedFrameSec === null ? "no decoded frame" : `${lastDecodedFrameSec.toFixed(3)}s`; - throw new Error( - `Video decode ended early at ${decodedAtLabel} (needed ${requiredEndSec.toFixed(3)}s).`, - ); + + if (isWindows) { + console.warn( + `[StreamingVideoDecoder] Decode ended early on Windows at ${decodedAtLabel} (needed ${requiredEndSec.toFixed(3)}s) – proceeding anyway.`, + ); + // Do not throw on Windows; allow export to complete with the frames we have. + } else { + throw new Error( + `Video decode ended early at ${decodedAtLabel} (needed ${requiredEndSec.toFixed(3)}s).`, + ); + } } }