← all posts site ↗

the cache stayed at zero songs

the offline caching build went on the phone and the counter just sat there. zero songs, every time i looked. the settings screen was finally wired up and the sliders moved, but nothing would ever download because the cache never saw a single candidate. every song played from the library was recorded under a numeric id, and the cache only accepted ids in the navidrome server format. so every play got thrown out as not a song before any download could start. nothing was broken at the end of the pipeline, it just never had anything to work with.

the fix was to stop trusting the id on the play event. the cache now resolves each played song through the library database to find its real server id and keys its rows on that. the offline player also looks up both key shapes, so it can actually serve the cached file when there's no connection. files land in the cache folder per server id and downloads start two at a time at original quality.

the build itself was a small saga. the first attempt died when the gradle daemon vanished, probably because earlier builds were still holding memory, so a fresh daemon got kicked off and the second try compiled clean. the new version is copied to the downloads folder, same filename as before, ready to install as a clean update. test plan is simple: install, play a few songs for a few seconds each, watch the counter leave zero, then airplane mode and play one of those songs again and it should come from cache. if it still sits at zero, the next suspects are the play rows never being written at all or the library sync not having the songs in the first place, and that means pulling phone logs.