central skip
This commit is contained in:
parent
063f14a7b4
commit
c8c0db493f
@ -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}/")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user