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
This commit is contained in:
parent
08e4d732f5
commit
80e2a7fc53
@ -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:
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user