From c8c0db493f4d3bb4908fa414d951c1e5566d57f0 Mon Sep 17 00:00:00 2001 From: lelo Date: Sat, 24 Jan 2026 15:18:50 +0000 Subject: [PATCH] central skip --- index_for_search.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/index_for_search.py b/index_for_search.py index 269b552..3f0d747 100755 --- a/index_for_search.py +++ b/index_for_search.py @@ -9,6 +9,7 @@ from collections import defaultdict SEARCH_DB_NAME = 'search.db' ACCESS_LOG_DB_NAME = 'access_log.db' FOLDER_CONFIG = 'folder_secret_config.json' +IGNORED_DIRS = {"Transkription", "@eaDir", ".app", "#recycle"} # Connect to the search database. search_db = sqlite3.connect(SEARCH_DB_NAME, check_same_thread=False) @@ -22,6 +23,11 @@ def log(message: str): """Small helper to ensure console output is flushed immediately.""" print(message, flush=True) + +def skip_dir(name: str) -> bool: + """Return True when a directory name should be skipped during traversal/logging.""" + return name.startswith('.') or name in IGNORED_DIRS + def init_db(): """Initializes the database with the required schema.""" cursor = search_db.cursor() @@ -60,9 +66,7 @@ def scan_dir(directory): for entry in it: if entry.is_dir(follow_symlinks=False): # Skip unwanted directories immediately. - if entry.name.startswith(('.', '@', '#')): - continue - if entry.name.lower() in {"transkription", ".app", "#recycle"}: + if skip_dir(entry.name): continue yield from scan_dir(entry.path) elif entry.is_file(follow_symlinks=False): @@ -106,9 +110,7 @@ def log_structure(root_path, max_depth=None, show_files=False): entries = sorted(it, key=lambda e: (not e.is_dir(follow_symlinks=False), e.name.lower())) for entry in entries: if entry.is_dir(follow_symlinks=False): - if entry.name.startswith(('.')): - continue - if entry.name in {"Transkription", "@eaDir", ".app", "#recycle"}: + if skip_dir(entry.name): continue indent = " " * (depth - 1) log(f"{indent}- {entry.name}/")