xbmc/xbmc — pull request #4795 by Montellese (2014-05-25 15:22:59+00:00)
Title: videodb: fixes for support of temporarily offline sources during library cleaning

After the release of Gotham it has been brought to my attention that there are (at least) two issues with the new logic to not remove items belonging to a temporarily offline source during video library cleaning:
* if a source is temporarily offline and the user chooses not to remove the items from that source (which is also the silent default behaviour when using "clean on update") we would still delete the entry of the source from the path table which results in the source being completely unset in XBMC i.e. the user has to re-assign the media type and the scraper.
* if the folder structure/hierarchy of a movie source contains multiple levels like movies/action/James Bond/Skyfall/Skyfall.mkv (i.e. not just movies/Skyfall/Skyfall.mkv) the current logic uses its parent path (in this example /movies/action/James Bond/) and handles it as if it was the source path which is obviously wrong. I wrote this code under the invalid assumption that the parent path ID stored for movies etc. is the path ID of the source path but it instead is the path ID of the parent path. Therefore we need to find the source path of the missing path (which is done with the new method CVideoDatabase::GetSourcePath()) and use that to check if the whole source is gone or not.

The first commit fixing the first issue should IMO be backported to Gotham if there's another fix release as unsetting a source will result in the library update not picking up any new items once the source is online again.

I'm not 100% sure about backporting the second and third commit fixing the second issue. The issue only results in some additional popup dialogs being thrown in the users face during library cleaning (which is annoying but pretty obvious) so it doesn't really break anything (except usability a bit).

@jmarshallnz for review.