refactor: extract should_include_path to utils module to resolve circular import between indexer and attachment_indexer

This commit is contained in:
2026-03-26 09:10:09 -04:00
parent 9e42fb072b
commit fe3ffe5860
3 changed files with 40 additions and 36 deletions
+35
View File
@@ -0,0 +1,35 @@
"""Utility functions shared across backend modules."""
from typing import Dict, Any, Tuple
def should_include_path(rel_parts: Tuple[str, ...], vault_config: Dict[str, Any]) -> bool:
"""Check if a path should be included based on hidden files configuration.
Args:
rel_parts: Tuple of path parts relative to vault root
vault_config: Vault configuration dict with includeHidden and hiddenWhitelist
Returns:
True if the path should be included, False otherwise
"""
include_hidden = vault_config.get("includeHidden", False)
hidden_whitelist = vault_config.get("hiddenWhitelist", [])
# Check if any part of the path starts with a dot (hidden)
hidden_parts = [part for part in rel_parts if part.startswith(".")]
if not hidden_parts:
# No hidden parts, always include
return True
if include_hidden:
# Include all hidden files/folders
return True
# Check if any hidden part is in the whitelist
for hidden_part in hidden_parts:
if hidden_part in hidden_whitelist:
return True
# Not in whitelist and includeHidden is False
return False