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.
pull/253/head
Broque Thomas 2 months ago
parent 11b1222c90
commit ade189fa38

@ -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

Loading…
Cancel
Save