Added more logging DiskScanProvider.CleanUp.

pull/4/head
Mark McDowall 13 years ago
parent 28259bc254
commit 2856c3dca3

@ -215,19 +215,28 @@ namespace NzbDrone.Core.Providers
{ {
foreach (var episodeFile in 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); if(!_diskProvider.FileExists(episodeFile.Path))
//Set the EpisodeFileId for each episode attached to this file to 0
foreach (var episode in _episodeProvider.GetEpisodesByFileId(episodeFile.EpisodeFileId))
{ {
episode.EpisodeFileId = 0; Logger.Trace("File [{0}] no longer exists on disk. removing from db", episodeFile.Path);
_episodeProvider.UpdateEpisode(episode);
//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);
} }
}
//Delete it from the DB catch (Exception ex)
_mediaFileProvider.Delete(episodeFile.EpisodeFileId); {
Logger.WarnException(ex.Message, ex);
} }
} }
} }

Loading…
Cancel
Save