Open tkem opened 9 years ago
The database should also store image width and height, which are now encoded in the image path.
Since a mapping of URIs to images will be available, this can also be used to (optionally) add image URIs to album models on lookup`.
Cleanup should be handled using database triggers. For example, if the last track is removed for an image, all other model mappings for that image must be removed, too, and the file deleted from disk.
Looks like (at least) three tables are needed for this:
image (path, width, height, ...)
track_model (track_uri, model_uri, ...)
model_image (model_uri, image_path)
Deleting a track will delete the model_image
and all track_model
records for that track.
Deleting a track_model
will delete all model_image
records for that model, unless the model is referenced by another track.
Deleting a model_image
will delete the image unless referenced otherwise.
This definitely needs some unit tests...
Mopidy v1.0
Library.get_images()
allows retrieving images for any URI, not just tracks. To facilitate this, a mapping of URIs to image paths should be kept, probably in an SQLite database. Since the local scanner only provides a track URI in the model passed tolocal.Library.add()
, the implementation needs too first calladd()
and thenlookup
on the delegate library to extract any album or artist URIs assigned by Mopidy-Local-SQLite, for example.