From ade189fa3817facf9add5be85c6345e9291b9a44 Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Thu, 19 Mar 2026 10:36:21 -0700 Subject: [PATCH] Fix Library Reorganize producing (_) in paths when year is empty _sanitize_context_values passed empty strings through _sanitize_filename which converts '' to '_' (empty-name fallback). Template $album ($year) became Album (_) instead of Album () which the cleanup regex couldn't match. Now preserves empty strings so the existing () cleanup works. --- core/repair_jobs/library_reorganize.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/repair_jobs/library_reorganize.py b/core/repair_jobs/library_reorganize.py index ecd6d9f6..66035dbb 100644 --- a/core/repair_jobs/library_reorganize.py +++ b/core/repair_jobs/library_reorganize.py @@ -58,11 +58,15 @@ def _sanitize_filename(filename: str) -> str: def _sanitize_context_values(context: dict) -> dict: - """Sanitize all string values for path safety.""" + """Sanitize all string values for path safety. + + Empty strings are preserved so that template cleanup regexes can + remove surrounding decorators (e.g. ``($year)`` → ``()`` → removed). + """ sanitized = {} for key, value in context.items(): if isinstance(value, str): - sanitized[key] = _sanitize_filename(value) + sanitized[key] = _sanitize_filename(value) if value else '' else: sanitized[key] = value return sanitized