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
|
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.
|
"""Synchronously read and parse a single file for indexing.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
vault_name: Name of the vault.
|
vault_name: Name of the vault.
|
||||||
vault_path: Absolute path to vault root.
|
vault_path: Absolute path to vault root.
|
||||||
file_path: Absolute path to the file.
|
file_path: Absolute path to the file.
|
||||||
|
vault_cfg: Optional vault configuration dict with hidden files settings.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
File info dict or None if the file cannot be read.
|
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)
|
relative = fpath.relative_to(vault_root)
|
||||||
rel_parts = relative.parts
|
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
|
return None
|
||||||
|
|
||||||
ext = fpath.suffix.lower()
|
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:
|
if not vault_path:
|
||||||
return None
|
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()
|
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()
|
lock = _get_async_lock()
|
||||||
async with 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
|
# Include all hidden files/folders
|
||||||
return True
|
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:
|
for hidden_part in hidden_parts:
|
||||||
if hidden_part in hidden_whitelist:
|
if hidden_part not in hidden_whitelist:
|
||||||
return True
|
return False
|
||||||
|
|
||||||
# Not in whitelist and includeHidden is False
|
# All hidden parts are in the whitelist
|
||||||
return False
|
return True
|
||||||
|
|||||||
@ -3425,13 +3425,16 @@
|
|||||||
|
|
||||||
async function reindexWithHiddenFiles() {
|
async function reindexWithHiddenFiles() {
|
||||||
const btn = document.getElementById("cfg-reindex-hidden");
|
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 {
|
try {
|
||||||
// First save the settings
|
// First save the settings to ensure they are persisted
|
||||||
await saveHiddenFilesSettings();
|
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");
|
await api("/api/index/reload");
|
||||||
showToast("✓ Réindexation terminée", "success");
|
showToast("✓ Réindexation terminée", "success");
|
||||||
loadDiagnostics();
|
loadDiagnostics();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user