From f920023ecfa80324005bedf8f98aa85d5c3ed79b Mon Sep 17 00:00:00 2001 From: pptx704 Date: Mon, 13 Apr 2026 02:57:38 +0600 Subject: [PATCH] Block download for non-regular files in file browser Disable the download button for symlinks and show a dedicated preview pane explaining the symlink target and suggesting to navigate to the target file instead. Guard handleDownload against non-file types as a safety net. --- frontend/src/lib/components/FilesTab.svelte | 34 +++++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/components/FilesTab.svelte b/frontend/src/lib/components/FilesTab.svelte index db7937f..49c388b 100644 --- a/frontend/src/lib/components/FilesTab.svelte +++ b/frontend/src/lib/components/FilesTab.svelte @@ -91,6 +91,10 @@ const canGoUp = $derived(currentPath !== '/' && currentPath.startsWith('/')); + // Only regular files can be downloaded — symlinks and other non-regular types + // may point to devices, sockets, or directories that can't be read as a file. + const isDownloadable = $derived(selectedFile?.type === 'file'); + async function navigateTo(path: string) { // Abort any in-flight file read and invalidate stale generation so the // abort error isn't surfaced in the UI. @@ -215,7 +219,7 @@ } async function handleDownload() { - if (!selectedFile || downloading) return; + if (!selectedFile || downloading || selectedFile.type !== 'file') return; downloading = true; try { await downloadFile(capsuleId, selectedFile.path, selectedFile.name); @@ -678,7 +682,8 @@ {formatFileSize(selectedFile.size)}