mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-26 01:27:00 +00:00
Added more logging DiskScanProvider.CleanUp.
This commit is contained in:
parent
28259bc254
commit
2856c3dca3
1 changed files with 19 additions and 10 deletions
|
@ -215,19 +215,28 @@ public virtual void CleanUp(IList<EpisodeFile> files)
|
|||
{
|
||||
foreach (var episodeFile in files)
|
||||
{
|
||||
if (!_diskProvider.FileExists(episodeFile.Path))
|
||||
try
|
||||
{
|
||||
Logger.Trace("File [{0}] no longer exists on disk. removing from db", episodeFile.Path);
|
||||
|
||||
//Set the EpisodeFileId for each episode attached to this file to 0
|
||||
foreach (var episode in _episodeProvider.GetEpisodesByFileId(episodeFile.EpisodeFileId))
|
||||
if(!_diskProvider.FileExists(episodeFile.Path))
|
||||
{
|
||||
episode.EpisodeFileId = 0;
|
||||
_episodeProvider.UpdateEpisode(episode);
|
||||
}
|
||||
Logger.Trace("File [{0}] no longer exists on disk. removing from db", episodeFile.Path);
|
||||
|
||||
//Delete it from the DB
|
||||
_mediaFileProvider.Delete(episodeFile.EpisodeFileId);
|
||||
//Set the EpisodeFileId for each episode attached to this file to 0
|
||||
foreach(var episode in _episodeProvider.GetEpisodesByFileId(episodeFile.EpisodeFileId))
|
||||
{
|
||||
Logger.Trace("Setting EpisodeFileId for Episode: [{0}] to 0");
|
||||
episode.EpisodeFileId = 0;
|
||||
_episodeProvider.UpdateEpisode(episode);
|
||||
}
|
||||
|
||||
//Delete it from the DB
|
||||
Logger.Trace("Removing EpisodeFile from DB.");
|
||||
_mediaFileProvider.Delete(episodeFile.EpisodeFileId);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WarnException(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue