From 84ff75f22307e881ead27c859a7e659627454dae Mon Sep 17 00:00:00 2001 From: Yuri Karamian Date: Tue, 23 Jun 2026 14:03:29 +0200 Subject: [PATCH] Fix #157: don't flag notebook folder icons as orphaned attachments --- src-tauri/src/commands.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index e0d5039..72639ad 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -1688,9 +1688,9 @@ pub struct OrphanAttachment { // Conservatively find files in .helixnotes/attachments not referenced by ANY note. Scans every // .md in the vault (including .helixnotes/trash, so a restorable trashed note keeps its files) -// and matches each filename against both the raw note text and a percent-decoded copy (so a -// URL-encoded path like `my%20file.png` still counts as a reference). When in doubt a file is -// KEPT: a leftover orphan is harmless, a wrong deletion is not. +// plus notebook_icons.json, and matches each filename against both the raw text and a +// percent-decoded copy (so a URL-encoded path like `my%20file.png` still counts as a reference). +// When in doubt a file is KEPT: a leftover orphan is harmless, a wrong deletion is not. fn scan_orphaned_attachments(vault: &str) -> Result, String> { let attachments_dir = operations::helixnotes_dir(vault).join("attachments"); if !attachments_dir.is_dir() { @@ -1719,6 +1719,12 @@ fn scan_orphaned_attachments(vault: &str) -> Result, String> } } } + // Folder icons live in attachments but are referenced here, not in notes. (#157) + let icons_path = operations::helixnotes_dir(vault).join("notebook_icons.json"); + if let Ok(content) = std::fs::read_to_string(&icons_path) { + haystack.push_str(&content); + haystack.push('\n'); + } let decoded = percent_decode(&haystack); let orphans = files .into_iter()