redesign of updateStandaloneArtwork() - #1637
Conversation
Signed-off-by: darrell-k <darrell@darrell.org.uk>
michaelherger
left a comment
There was a problem hiding this comment.
Thanks a lot! I hope to find time to actually test this later today. All my comments are just of theoretical nature. Haven't even pulled this change yet. Bear with me.
Signed-off-by: darrell-k <darrell@darrell.org.uk>
Signed-off-by: darrell-k <darrell@darrell.org.uk>
Signed-off-by: darrell-k <darrell@darrell.org.uk>
…de I used Signed-off-by: darrell-k <darrell@darrell.org.uk>
Signed-off-by: darrell-k <darrell@darrell.org.uk>
Signed-off-by: darrell-k <darrell@darrell.org.uk>
|
Some rework just pushed. |
michaelherger
left a comment
There was a problem hiding this comment.
I'm sorry, another sh..load of comments. I haven't even test run this yet, but I believe there's potential for performance optimisations on the DB level.
| # Maybe a track instance was passed in, but no longer from updateStandaloneArtwork() which gives us | ||
| # the trackid instead, as we only need to instantiate a track if 'titleformatter' artwork naming is in use. | ||
| my $track = $trackAttributes && delete $trackAttributes->{_track}; | ||
| $track ||= Slim::Schema->find('Track', $trackAttributes->{_trackid}) if $trackAttributes->{_trackid}; |
There was a problem hiding this comment.
Can we delete the _trackid element here?
|
Just to let you know, I'm currently testing the
|
|
I'm going to resolve some of the comments in this thread, it's getting hard to follow! |
|
I'm about to push an update. The scanned pics SQL now identifies the albums that need processing so that all tracks can be processed together even if the album's tracks are located in multiple folders. This makes it simpler, especially when we come to enhance this to look for specific album artwork (eg box sets). I hope I've also covered all the comments above. I'm ready for more questions/comments! |
Signed-off-by: darrell-k <darrell@darrell.org.uk>
The other way somehow failed scans on my machine. I wasn't able to run the scanner without this modification on my dev Mac. Signed-off-by: Michael Herger <michael@herger.net>
Move SQLite function registration to `SQLiteHelper`
Signed-off-by: darrell-k <darrell@darrell.org.uk>
Seperate scanner helper table initialisation
|
I'm so utterly confused... does this change even touch the full wipe & rescan case? And didn't we change the code (in 9.2 or before) to use |
There was a problem hiding this comment.
This has been sitting in my computer for way too long. And I'm still rather confused... these changes only deal with updated artwork on a rescan, but not the initial scan? Is this because we're happy with the initial scan at this point (except for boxsets)?
And as I mentioned in some other comment we don't handle album artwork independently of the track artwork yet? I'm very much confused because I had retagged some of my files about a month ago to test this particular case.
EDIT: ok, it seems the album artwork vs. track artwork was part of my attempt to deal with boxsets in #1627. Aargh... just wasted half an afternoon 😞.
| ### I might have missed it, but I can't see where this might be called in main process async mode. | ||
| ### If it is, we'll need more work to populate scanned_pics in the main process or just keep a version of the old subroutine for that use. |
There was a problem hiding this comment.
I did what people do nowadays: I asked the AI assistant. It told me that the easiest way to have the scan run in the main process was to do a rescan album <album_id>. I'll give that a try.
There was a problem hiding this comment.
I don't think that would call updateStandaloneArtwork and Schema.pm will still calculate a coverid if it can't find the image in scanned_images (if I remember correctly!).
Yes (until we get on to the box set changes), except that in Schema.pm we now read coverid directly from the enhanced And unless your refactoring of |
|
This PR is still in draft mode. How do you feel about it? I think we/I should try to get things moving again. Shall I merge? |
|
Let me address the outstanding comments first. Give me a day. And then, you mean merge into your artwork-scan-db branch and not 9.2? I think we should do the box set stuff before merging to 9.2 (it should be easy to incorporate into |
|
I've been testing the rescan album command. It does populate the Now we have a choice:
What do you think? After resolving this question, I'll push changes which hopefully cover all the comments I've resolved in the thread. |
If I understand your options correctly, then I'd prefer #2. I understand this would drop the table after the scan. As I mentioned before I'd like to use the same table for contributor picture lookups, where we currently do a ton of directory reading etc. Using the database should be so much more cleaner and efficient. BTW: I know, I asked you to keep the old |
I'm thinking that for consistency, we should treat At present, So I'm much preferring option 1. above. What are the problems you foresee with that approach? |
Quoting what you already quoted:
If we removed data from that table, the contributor picture scan would have to populate it again. It's too early to drop the data. We could drop it as part of the "optimize" step? |
I'm not understanding. Option (1) would follow what 9.2 is doing for
Either way, the data would be available to the contributor picture scan. |
Are you referring to this line? https://github.com/LMS-Community/slimserver/blob/public/9.2/Slim/Utils/Scanner/Local.pm#L66 |
I'm not understanding. Option (1) would follow what 9.2 is doing for
Either way, the data would be available to the contributor picture scan.
Yes, and also slimserver/Slim/Control/Commands.pm Lines 2760 to 2778 in c96f8f2 |
|
Ok, a month or two later I finally get it 🤦🏻. I'm not sure we should just add things there as deletion of found artwork references might actually be a bit more complex than tracks once we add box set handling, works etc. as we will have to look at parent folders too. We should probably not delete by folder, but by Do we populate the |
If we were to clear the data from
Yes for a single album scan, no for a single track scan, because we bypass slimserver/Slim/Utils/Scanner/Local.pm Lines 71 to 110 in c96f8f2 For the single album scan we are going to have to consider the parent folder question when we get on to box sets. For a single track scan, I think it's reasonable that artwork changes (unless embedded) is ignored. I would vote that for this PR we should go with the simple solution I'm suggesting and if it needs further amendment for box sets we can enhance it when we code that. NOTE: I thought I'd have a look at what 9.2 was doing and just found that it's not handling changed artwork properly anyway! Something else to incorporate in this PR!!! |
|
Should we merge what we have, and add more as we get more exposure? We don't have to fix everything in one go. |
|
Probably - I'll just check I haven't made anything worse. |
|
OK, the artwork problem in rescan album is hopefully fixed by calling I'm about to push the changes, hopefully this is ready to merge now, but I want to run all my tests again before I mark this "ready for review". That will be tomorrow afternoon. |
Signed-off-by: darrell-k <darrell@darrell.org.uk>
| # Populate enhanced scanned_pics table (status E = already exists in the tracks table, status N = new) | ||
| my $imageSth = $dbh->prepare_cached( qq{ | ||
| INSERT INTO scanned_pics | ||
| INSERT OR IGNORE INTO scanned_pics |
There was a problem hiding this comment.
They say that if you want to ignore only if it already exists, you should use INSERT ... ON CONFLICT DO NOTHING, rather than INSERT OR IGNORE. The latter would silently swallow other failures, like empty key values, which we might be interested to learn about. See eg. https://hoelz.ro/blog/with-sqlite-insert-or-ignore-is-often-not-what-you-want
| # XXX how best to delete files in non-recursive mode? | ||
| # Delete the directory itself and all children | ||
| $dbh->do("DELETE FROM scanned_files WHERE url = '${file}' OR url LIKE '${file}/%'"); | ||
| $dbh->do("DELETE FROM scanned_pics WHERE folder = '${path}'"); |
There was a problem hiding this comment.
I know, this has been around for 15+ years. But maybe it's time to do this correctly, using a prepared statement? Some paths when expanded this way might fail the query, eg. if they had quotes in them etc.
There was a problem hiding this comment.
This is a new change. As these are all purely scanner related, do we really want to bump the schema version? Keep in mind that this will force a full new rescan - for the only reason to run new scanner code. That's kind of stupid if all we change is the scanner process, but not the result (hopefully, anyway).
There was a problem hiding this comment.
On the other hand, IMO it's the "right" way to do it (following scanned_files). But I'm open to other ideas if we can ensure it's only created once, not dropped and recreated.
I could reinstate scannerInitialiseDB (or whatever I called it) from a previous commit. That could check for the table's existence and do nothing if it already exists. Checking for a table's existence is easier now we don't have to worry about mysql, but is it worth it?
There was a problem hiding this comment.
Or just CREATE TABLE IF NOT EXISTS, of course!
There was a problem hiding this comment.
You're right: a new schema version file the right thing to do. 9.2 is still in development.
Do we really need the additional index on tracks.cover? I think we never use that criteria without another more restrictive condition like eg. the album. Maintaining the index might take more time than we gain checking all tracks of an album with the help of the index vs. without?
As discussed. I hope it all makes sense.
The diff generated by git for
updateStandaloneArtwork()is a bit of a mess, probably best to view the new routine as a complete replacement for the old one.This redesign enhances the new
scanned_picstable so that it can driveupdateStandaloneArtwork().coveridcolumn so that we can read it directly from the table (in the scanner process) when we need to updatetracksoralbums. In order for this to work, all externalcoveridgeneration will now use the image path, not the music file URL.statuscolumn so we can differentiate new, existing and deleted images.urlcolumn is renamed topathas it will now hold the file system path of the image, not a file:// URL. This makes things much easier.dircolumn as discussed.In performance testing, this runs faster, even though we are now calling
findStandaloneArtwork()for every track where an image change has been detected, rather than only once for each album/image group.This change enables
TitleFormatterto do its work correctly in cases when the user has specified a variable cover id which includes a "sub-album" field likediscnumberorgrouping. This means that disc or grouping-specific images can be applied to tracks using this existing mechanism when everything for the album is in the same directory.I've added some comments to new/changed code in order to aid understanding.
I'm sure at this stage there is stuff I've missed.