fix: rating no longer reset to -1 during mount/sync from iPod Play Counts

The Play Counts parser uses rating=-1 as sentinel for 'no change',
but the merge logic used  which treats -1 as truthy, overwriting
real ratings with -1 in all three paths: mount-time sync (worker.py),
DB regeneration (_merge_play_stats), and track listing (get_all_tracks).
This commit is contained in:
Maksim Totmin 2026-06-01 19:45:32 +07:00
parent a36312c9d7
commit 309ba994a5
2 changed files with 6 additions and 3 deletions

View File

@ -485,7 +485,8 @@ class Nano7Database:
dd = delta_stats.get(location, {})
pc = bs.get("play_count", 0) + dd.get("play_count", 0)
sc = bs.get("skip_count", 0) + dd.get("skip_count", 0)
rating = dd.get("rating", 0) or bs.get("rating", 0)
dd_rt = dd.get("rating", 0)
rating = dd_rt if dd_rt >= 0 else bs.get("rating", 0)
tracks.append({
"pid": s["pid"],
"title": s.get("title") or os.path.splitext(s["file_name"])[0],
@ -660,7 +661,8 @@ class Nano7Database:
bs.get("skip_count", 0), local_pc.get("skip_count", 0),
) + dd.get("skip_count", 0)
s["rating"] = dd.get("rating", 0) or bs.get("rating", 0) or local_pc.get("rating", 0)
dd_rating = dd.get("rating", 0)
s["rating"] = dd_rating if dd_rating >= 0 else bs.get("rating", 0) or local_pc.get("rating", 0)
s["last_played"] = max(
bs.get("last_played", 0), local_pc.get("last_played", 0),

View File

@ -240,7 +240,8 @@ class WorkerThread(QThread):
entry.get("skip_count", 0), bs.get("skip_count", 0),
) + dd.get("skip_count", 0)
entry["rating"] = dd.get("rating", 0) or bs.get("rating", 0) or entry.get("rating", 0)
dd_rating = dd.get("rating", 0)
entry["rating"] = dd_rating if dd_rating >= 0 else bs.get("rating", 0) or entry.get("rating", 0)
entry["last_played"] = max(
entry.get("last_played", 0), bs.get("last_played", 0),