From b2cb216af0eabc342f5f31e9af3ea77b5b8deecf Mon Sep 17 00:00:00 2001 From: Steffen Becker Date: Thu, 3 Sep 2026 23:21:38 +0200 Subject: [PATCH] fix: a save that fails falls back to a new file only for a lost handle Any error but an encryption one went to Save As, which hid exporter bugs and silently turned a .docx document into .odt. Only a handle that lost its permission or its file prompts again now, in the document's format. --- src/App.svelte | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index b9e6b21..9feb32e 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -880,9 +880,10 @@ recentFiles = await rememberRecentFile(fileHandle?.name ?? suggestedFilename(json), fileHandle); } catch (err) { if ((err as DOMException)?.name === 'AbortError') return; - // A stored handle may have lost permission; re-prompt via Save As. Encryption - // failing is not that case — it would silently save the document unprotected. - if (fileHandle && (err as Error)?.name !== 'EncryptionError') { fileHandle = null; await handleSaveAs(); return; } + // A stored handle may have lost its permission or its file: prompt for a new one, + // in the document's own format. Every other error is reported, not papered over. + const name = (err as DOMException)?.name; + if (fileHandle && (name === 'NotAllowedError' || name === 'NotFoundError')) { fileHandle = null; return handleSave(); } console.error('[save] Failed to save file:', err); failed(t().dialogs.couldNotSave, err); }