Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new artwork, where previously none, not picked up until after library rescan #1173

Open
whatdoineed2do opened this issue Jan 17, 2021 · 2 comments
Labels

Comments

@whatdoineed2do
Copy link
Contributor

Similar issue being resolved by #1171 (replaced artwork not picked up)

If you have NO local artwork for an album any new local artwork added will NOT be picked up until after a library rescan. To reproduce:

  • add album foo with no cover.jpg etc
  • visit web front end for album, observe the auto generated album artwork (as expected)
    • cache was empty for this persistent id but a new empty row is created which has NO data blob
  • copy local artwork ie cover.jpg to album foo directory
  • wait for cache to update
  • navigate to search and revisit album foo - auto generated album artwork still shown BUG
    • cache is not updated

This occurs in a spot that is a little difficult to solve.

  • when client asks for artwork, the backend looks through its handlers: cache, directory
  • the first time this is asked, it won't find it in the neither handler
#0  0x00000000004497ef in source_group_cache_get (ctx=0x7f6629ff8720) at artwork.c:1336
#1  0x000000000044aa9d in process_group (ctx=0x7f6629ff8720) at artwork.c:1878
#2  0x000000000044affa in artwork_get_group (evbuf=0x7f6618054d70, id=4251, max_w=0, max_h=0, format=0) at artwork.c:1993
#3  0x0000000000441c94 in artworkapi_reply_group (hreq=0x7f6618054d20) at httpd_artworkapi.c:137
#4  0x0000000000441e11 in artworkapi_request (req=0x7f6618054940, uri_parsed=0x7f6618054b40) at httpd_artworkapi.c:174
  • an empty entry (no data column) is added
[2021-01-17 20:31:05] [DEBUG]      web: Artwork api request: '/artwork/group/4251'
[2021-01-17 20:31:05] [DEBUG]  artwork: Artwork request for group 4251 (max_w=0, max_h=0)
[2021-01-17 20:31:05] [DEBUG]    cache: Running query 'SELECT a.format, a.data, LENGTH(a.data) IS NOT NULL as has_data FROM artwork a WHERE a.type = 0 AND a.persistentid = 5299105057672392192 AND a.max_w = 0;'
[2021-01-17 20:31:05] [DEBUG]    cache: No results
[2021-01-17 20:31:05] [DEBUG]  artwork: source cache persistent id: 5299105057672392192 cached: 0 format: 0  datalen: 0
[2021-01-17 20:31:05] [  LOG]  artwork: artwork get:  grpret: -1  ctx.cache 2  ON_SUCCEESS 0  ON_FAILURE 2
[2021-01-17 20:31:05] [DEBUG]  artwork: No artwork found for group 4251
[2021-01-17 20:31:05] [  LOG]    cache: insert into artwork: persistentid 5299105057672392192  datalen 0

https://github.com/ejurgensen/forked-daapd/blob/5ece7b9591031b6060c5c9d735f92e621d8402c7/src/artwork.c#L1997-L2002

  • subsequent client requests for artwork, the server finds this empty entry and believes its cached and sends back this emty reponse to client
[2021-01-17 20:31:25] [DEBUG]      web: Artwork api request: '/artwork/group/4251'
[2021-01-17 20:31:25] [DEBUG]  artwork: Artwork request for group 4251 (max_w=0, max_h=0)
[2021-01-17 20:31:25] [DEBUG]    cache: Running query 'SELECT a.format, a.data, LENGTH(a.data) IS NOT NULL as has_data FROM artwork a WHERE a.type = 0 AND a.persistentid = 5299105057672392192 AND a.max_w = 0;'
[2021-01-17 20:31:25] [DEBUG]    cache: Cache hit: SELECT a.format, a.data, LENGTH(a.data) IS NOT NULL as has_data FROM artwork a WHERE a.type = 0 AND a.persistentid = 5299105057672392192 AND a.max_w = 0;
[2021-01-17 20:31:25] [DEBUG]  artwork: source cache persistent id: 5299105057672392192 cached: 1 format: 0  datalen: 0
[2021-01-17 20:31:25] [DEBUG]  artwork: Source 'cache' stopped search for artwork for group 5299105057672392192
[2021-01-17 20:31:25] [  LOG]  artwork: artwork get:  grpret: -1  ctx.cache 0  ON_SUCCEESS 0  ON_FAILURE 0
[2021-01-17 20:31:25] [DEBUG]  artwork: No artwork found for group 4251

This is where there is a sticky problem - if you add real local artwork for this album now, the artwork backend will never get to the directory handler to look locally again. Second time we look for artwork, the existance of the cached empty value is enough to prevent the server looking further

Any thoughts on how best to fix this?

The filescanner, upon finding new local artwork for a group could try go and invalidate/clear out this empty row but is that clean enough? It looks like there'd be trouble mapping the new artwork file with group persistent id (since theres no filename in the cache (theres no previous artwork file) to tie this together.

@ejurgensen
Copy link
Member

There's a lot of info here, but as you say negative results are also cached, and that is by design. So to me it sounds like the problem is the same as with the other issue, which is how to determine which files are possibly affected by an artwork update on the filesystem. I don't know what the right solution is for that, haven't looked at your PR yet.

@whatdoineed2do
Copy link
Contributor Author

The other issue is related to the change to the image in the library (and potentially fetched from the cache as the real image) not being refreshed at the web browser side. To make that happen I've added a "version" on the artwork_url to force vuejs and its image caching to know theres's a new image (because the "version" is time it was modifed in the db).

For this issue we have a problem trying to force the negative/empty cache entry to be invalidated because we know new artwork is available for this album so that the artwork/cache goes and looks at the directory again and finds the new artwork. This has proved a little painful since the cache on empty cache entries have no filepath (theres no path to the non-existant artwork but a persistentid) and when scanning its difficult/impossible to tie an artwork to a group's persistentid.

When a library_rescan happens things are reset cleanly - so there's a workaround for invalidating an emty cache item but it needs us to rescan the entire library which is a little wasteful. I've added PR to allow the server to do partial local rescans (something i've thought about in the past and theres and outstanding functionlity request anyway) so this could be the way to solve this.

@ejurgensen ejurgensen added the bug label Jan 27, 2021
@ejurgensen ejurgensen changed the title BUG: adding new artwork, where previously none, not picked up until after library rescan Adding new artwork, where previously none, not picked up until after library rescan Jan 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants