Scope fuzzy key match to username and add lock
Tighten fuzzy matching in post-processing when no exact context is found: acquire matched_context_lock for thread-safe access and limit candidate keys to those starting with the current username prefix ("{task_username}::") while still matching the file basename. This prevents cross-album/username metadata contamination during mass downloads (e.g., multiple albums with identical track basenames) and reduces erroneous fuzzy matches.
This commit is contained in:
parent
f772bf9e5e
commit
58df2ba33c
1 changed files with 6 additions and 1 deletions
|
|
@ -13929,7 +13929,12 @@ def _run_post_processing_worker(task_id, batch_id):
|
|||
else:
|
||||
print(f"❌ [Post-Processing] No context found for key: {context_key}")
|
||||
# Try fuzzy matching with similar keys containing the filename
|
||||
similar_keys = [k for k in matched_downloads_context.keys() if task_basename in k]
|
||||
# SAFETY: Constrain to same Soulseek username to prevent cross-album
|
||||
# metadata contamination during mass downloads (e.g., two albums both
|
||||
# having "01 - Intro.flac" would match the wrong context without this)
|
||||
with matched_context_lock:
|
||||
similar_keys = [k for k in matched_downloads_context.keys()
|
||||
if k.startswith(f"{task_username}::") and task_basename in k]
|
||||
if similar_keys:
|
||||
# Use the first similar key found
|
||||
fuzzy_key = similar_keys[0]
|
||||
|
|
|
|||
Loading…
Reference in a new issue