librespot
librespot copied to clipboard
Limit cache size
For people running librespot on hardware with limited resources, it would be nice to have an option to limit the cache size.
This is definitely something I'd like to have, but requires quite a bit of work. At the moment, caching is just a matter of placing the file in the cache directory, and trying to open it when loading.
This requires some bookkeeping to keep track of what files are in the cache, their size, along with an eviction algorithm.
These could be used as inspiration, although librespot doesn't need something as sophisticated : https://wiki.mozilla.org/Necko/Cache https://www.chromium.org/developers/design-documents/network-stack/disk-cache
For the moment, users that face issues with it, they could make a simple cron-job that checks the atime of files tp clean-up.
@mfonville how is this possible? If I run find /tmp/librespot/files/* -atime +2 -exec rm {} \;
it crashes librespot. The only way I can get it to work is to stop the librespot service, clear up the files and start it again. If I do this, the music will stop when playing, so it doesn't seem to be the most ideal solution yet :)
@juriansluiman Deleting files while librespot is running should work.
Can you run librespot with RUST_BACKTRACE=1
and --verbose
and post the log please ? What platform are you running on ?
@plietar sorry, you get forget my comment. I was having another issue with librespot so it stopped working, but just tried again and it does continue to play. My bad!
I've modified librespot to disable the audio file-cache. See pull request #181.