ejurgensen/forked-daapd — pull request #58 by chme (2014-10-19 06:33:52+00:00)
Title: Artwork caching

Finally i found some time to start working on this again. It is still not finished yet, but i think it's in a "good enough" state for a first review.

The first 6 commits are a refactoring of the logic how forked-daapd loads an artwork image. It removes the functionality of separate artworks for tracks and parent directory artwork. So now an artwork file is always associated to a (persistent) group id.

The cache now uses a single table to store the resized images:

CREATE TABLE IF NOT EXISTS artwork (
id INTEGER PRIMARY KEY NOT NULL,
persistentid INTEGER NOT NULL,
max_w INTEGER NOT NULL,
max_h INTEGER NOT NULL,
format INTEGER NOT NULL,
filepath VARCHAR(4096) NOT NULL,
db_timestamp INTEGER DEFAULT 0,
data BLOB
);

The fields persistentid, max_w, max_h are necessary to identify a cached image, format contains the information if it is a jpg, png or there does not exist an artwork file. The fields filepath and db_timestamp are necessary to check if the cached image needs to be updated.

If there is no artwork for a persistentid the cache stores an entry with format = 0 and an empty filepath. After a bulk scan all entries with an empty filepath will be deleted. The same should happen with spotify images. I don't have a spotify account, so i could not test this.

Feedback very welcome!