Bug 4812 - Rescan done callback not called in all situations
: Rescan done callback not called in all situations
Status: RESOLVED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Scanner
: 7.0
: All All
: P2 enhancement with 1 vote (vote)
: ---
Assigned To: Squeezebox QA Team email alias
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-03-07 12:44 UTC by Stuart Hickinbottom
Modified: 2008-12-18 11:12 UTC (History)
1 user (show)

See Also:
Category: ---


Attachments
Proposedfix for case 4 - new music found with Browse Music Folder (487 bytes, patch)
2007-03-07 14:15 UTC, Stuart Hickinbottom
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stuart Hickinbottom 2007-03-07 12:44:36 UTC
This report was raised from the following forums thread:
http://forums.slimdevices.com/showthread.php?t=33367

Some plugins are very interested whenever new information has been added to the SlimServer database so that they can add their own plugin-specific information about that new data. Such plugins register a callback function to try to get that notification as follows:

Slim::Control::Request::subscribe(
        \&Plugins::MyPlugin::Plugin::scanDoneCallback,
        [ ['rescan'], ['done'] ] );

The limitation with this is that this callback is not invoked in all situations that data can have been added to the database. It seems to work in the following situations:

1. The music library location is changed through server settings.
2. The user performs a "rescan" through the server settings (clear-and-rescan or look-for-changes).
3. An automatic scheduled rescan has been performed.

However, it *does not* appear to be called in the following situations:

4. New music is discovered during Browse Music Folder (it is added to the database, though).
5. New music is discovered by a periodic check of the MusicIP database.

(there may be other cases that I've not thought of - iTunes might be one, but I don't use it so can't test whether that's the case or not)

To illustrate the problem, my own Lazy Search Music plugin wants to know when something has been added to the database so it can compute and store a more easily searchable version in the database. If music is added to the database without the rescan done callback being called then the end result is that music isn't searchable until a manual rescan is performed. I don't believe this issue is restricted to my plugin, however, as the thread mentioned above shows.
Comment 1 Stuart Hickinbottom 2007-03-07 14:15:54 UTC
Created attachment 1832 [details]
Proposedfix for case 4 - new music found with Browse Music Folder

This is a very small patch that makes SlimServer call the 'rescan done' hook whenever browsing into a music folder has discovered something new. This covers genuinely new files and folders, and also touched files and folders with an updated mtime.
Comment 2 Stuart Hickinbottom 2007-03-07 15:08:48 UTC
Having done a little more testing I believe the rescan done callback *is* called when new music is imported from MusicIP when SlimServer notices the MusicIP cache has been touched, so there's nothing to fix for that case.

That leaves Browse Music Folder, though, so the attached patch is still relevant for that.
Comment 3 Andy Grundman 2007-05-18 11:29:51 UTC
This should be OK to put in 6.5.3.
Comment 4 KDF 2007-05-22 20:37:16 UTC
merged to trunk at change 12091
and to 6.5.x at change 12092

please updates specs, tests and reopen if there are any issues.