Rettelser og reset

This commit is contained in:
2026-04-19 11:28:28 +02:00
parent f0a4b4dfa7
commit 80407e98fb
8 changed files with 148 additions and 19 deletions

View File

@@ -54,10 +54,10 @@ class SyncManager:
def _run():
try:
payload = self._build_push_payload()
logger.info(f"Push: {len(payload['songs'])} sange, {len(payload['playlists'])} playlister")
logger.info(f"Push OK: {len(payload['songs'])} sange")
result = self._post("/sync/push", payload)
self._save_playlist_ids(result.get("playlist_id_map", {}))
logger.info(f"Push OK: {result}")
logger.info(f"Push OK: {result.get('songs_synced', '?')} sange synkroniseret")
if on_done:
on_done(result)
except Exception as e:
@@ -88,9 +88,7 @@ class SyncManager:
try:
result = self._get("/sync/pull")
pl_count = len(result.get("my_playlists", []))
logger.info(f"Pull: {len(result.get('dances', []))} danse, {pl_count} playlister")
for pl in result.get("my_playlists", []):
logger.info(f" Playliste fra server: '{pl['name']}' ({len(pl.get('songs',[]))} sange)")
logger.info(f"Pull OK: {pl_count} playlister")
self._apply_pull(result)
if on_done:
on_done(result)
@@ -104,16 +102,15 @@ class SyncManager:
"""Push og derefter pull i samme tråd."""
def _run():
try:
logger.info("push_and_pull: bygger payload...")
payload = self._build_push_payload()
logger.info(f"push_and_pull: sender {len(payload['songs'])} sange, {len(payload['playlists'])} playlister")
push_result = self._post("/sync/push", payload)
logger.info(f"push_and_pull: push OK — {push_result}")
pull_result = self._get("/sync/pull")
pl_count = len(pull_result.get("my_playlists", []))
logger.info(f"push_and_pull: pull OK — {pl_count} playlister")
for pl in pull_result.get("my_playlists", []):
logger.info(f" Playliste: '{pl['name']}' ({len(pl.get('songs',[]))} sange)")
logger.info(
f"Sync OK — {len(payload['songs'])} sange, "
f"{len(payload['playlists'])} playlister, "
f"{pl_count} server-playlister"
)
self._apply_pull(pull_result)
if on_done:
on_done({"push": push_result, "pull": pull_result})