From 80e2a7fc53d02bdcbf7c1785f6691c023f8fb8eb Mon Sep 17 00:00:00 2001 From: Bruno Charest Date: Thu, 26 Mar 2026 14:14:04 -0400 Subject: [PATCH] feat: fix hidden files whitelist logic to require ALL hidden path components be whitelisted, add vault config to single file indexing, and improve reindex button feedback with save phase indication --- backend/indexer.py | 14 +++++++++++--- backend/utils.py | 11 ++++++----- frontend/app.js | 9 ++++++--- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/backend/indexer.py b/backend/indexer.py index 9af436c..28c2030 100644 --- a/backend/indexer.py +++ b/backend/indexer.py @@ -444,13 +444,14 @@ def _get_async_lock() -> asyncio.Lock: return _async_index_lock -def _index_single_file_sync(vault_name: str, vault_path: str, file_path: str) -> Optional[Dict[str, Any]]: +def _index_single_file_sync(vault_name: str, vault_path: str, file_path: str, vault_cfg: Optional[Dict[str, Any]] = None) -> Optional[Dict[str, Any]]: """Synchronously read and parse a single file for indexing. Args: vault_name: Name of the vault. vault_path: Absolute path to vault root. file_path: Absolute path to the file. + vault_cfg: Optional vault configuration dict with hidden files settings. Returns: File info dict or None if the file cannot be read. @@ -464,7 +465,11 @@ def _index_single_file_sync(vault_name: str, vault_path: str, file_path: str) -> relative = fpath.relative_to(vault_root) rel_parts = relative.parts - if any(part.startswith(".") for part in rel_parts): + + # Check if path should be included based on hidden files configuration + if vault_cfg is None: + vault_cfg = {"includeHidden": False, "hiddenWhitelist": []} + if not should_include_path(rel_parts, vault_cfg): return None ext = fpath.suffix.lower() @@ -614,8 +619,11 @@ async def update_single_file(vault_name: str, abs_file_path: str) -> Optional[Di if not vault_path: return None + # Get vault configuration for hidden files handling + vault_cfg = vault_data.get("config") or vault_config.get(vault_name, {}) + loop = asyncio.get_event_loop() - file_info = await loop.run_in_executor(None, _index_single_file_sync, vault_name, vault_path, abs_file_path) + file_info = await loop.run_in_executor(None, _index_single_file_sync, vault_name, vault_path, abs_file_path, vault_cfg) lock = _get_async_lock() async with lock: diff --git a/backend/utils.py b/backend/utils.py index d13b9da..18268bc 100644 --- a/backend/utils.py +++ b/backend/utils.py @@ -26,10 +26,11 @@ def should_include_path(rel_parts: Tuple[str, ...], vault_config: Dict[str, Any] # Include all hidden files/folders return True - # Check if any hidden part is in the whitelist + # Check if ALL hidden parts are in the whitelist + # If any hidden part is NOT in the whitelist, exclude the path for hidden_part in hidden_parts: - if hidden_part in hidden_whitelist: - return True + if hidden_part not in hidden_whitelist: + return False - # Not in whitelist and includeHidden is False - return False + # All hidden parts are in the whitelist + return True diff --git a/frontend/app.js b/frontend/app.js index bfcea66..d8bd85d 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -3425,13 +3425,16 @@ async function reindexWithHiddenFiles() { const btn = document.getElementById("cfg-reindex-hidden"); - if (btn) { btn.disabled = true; btn.textContent = "⏳ Réindexation..."; } + if (btn) { btn.disabled = true; btn.textContent = "💾 Sauvegarde..."; } try { - // First save the settings + // First save the settings to ensure they are persisted await saveHiddenFilesSettings(); - // Then trigger reindex + // Update button text to show reindexing phase + if (btn) { btn.textContent = "⏳ Réindexation..."; } + + // Then trigger reindex with saved settings await api("/api/index/reload"); showToast("✓ Réindexation terminée", "success"); loadDiagnostics();