From 7fb1b115f05584da32f7929dec1d87b18167494d Mon Sep 17 00:00:00 2001 From: BoulderBadgeDad Date: Fri, 12 Jun 2026 16:49:52 -0700 Subject: [PATCH] Playlists: also run the reconcile on the V2 batch-completion path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit on_download_completed and check_batch_completion_v2 are duplicate completion paths. Monitor-detected downloads (Deezer / slskd-monitor / verification-worker imports) finish the batch via the V2 path, but the materialize reconcile was only added to on_download_completed — so those batches never built playlist folders (no '[Playlist Folder] Rebuilt' line at all). Add the same non-fatal reconcile to the V2 path. Now all three completion points (both lifecycle paths + the master.py all-owned path) materialize. 550 tests pass. --- core/downloads/lifecycle.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/downloads/lifecycle.py b/core/downloads/lifecycle.py index 68054ccc..e8abeede 100644 --- a/core/downloads/lifecycle.py +++ b/core/downloads/lifecycle.py @@ -752,6 +752,22 @@ def check_batch_completion_v2(batch_id: str, deps: LifecycleDeps) -> Optional[bo deps.download_monitor.stop_monitoring(batch_id) _cleanup_private_album_bundle_staging(batch_id, batch) + # PLAYLIST MATERIALIZE: same reconcile as the primary completion path + # (on_download_completed). Monitor-detected downloads complete via THIS + # V2 path, so the reconcile must run here too or playlist folders never + # get built for them. Path-independent, non-fatal, derived view. + try: + from core.playlists.materialize_service import reconcile_batch_playlists + for _pl_name, _mat in reconcile_batch_playlists(batch, download_tasks, deps.config_manager): + logger.info( + f"[Playlist Folder] Rebuilt '{_mat.playlist_dir}': " + f"{_mat.linked} linked, {_mat.copied} copied, " + f"{_mat.unchanged} unchanged, {_mat.removed_stale} stale removed" + + (" (symlinks unsupported here → copied)" if _mat.fellback else "") + ) + except Exception as _mat_err: + logger.error(f"[Playlist Folder] Materialize failed (non-fatal): {_mat_err}") + # REPAIR: Scan all album folders from this batch for track number issues if deps.repair_worker: deps.repair_worker.process_batch(batch_id)