Bugzilla – Bug 4812
Rescan done callback not called in all situations
Last modified: 2008-12-18 11:12:12 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.
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.
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.
This should be OK to put in 6.5.3.
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.