diff --git a/src/NzbDrone.Core/Music/Utilities/ShouldRefreshAlbum.cs b/src/NzbDrone.Core/Music/Utilities/ShouldRefreshAlbum.cs index 5dac303ce..f21c6d70c 100644 --- a/src/NzbDrone.Core/Music/Utilities/ShouldRefreshAlbum.cs +++ b/src/NzbDrone.Core/Music/Utilities/ShouldRefreshAlbum.cs @@ -19,26 +19,34 @@ namespace NzbDrone.Core.Music public bool ShouldRefresh(Album album) { - if (album.LastInfoSync < DateTime.UtcNow.AddDays(-60)) + try { - _logger.Trace("Album {0} last updated more than 60 days ago, should refresh.", album.Title); - return true; - } + if (album.LastInfoSync < DateTime.UtcNow.AddDays(-60)) + { + _logger.Trace("Album {0} last updated more than 60 days ago, should refresh.", album.Title); + return true; + } - if (album.LastInfoSync >= DateTime.UtcNow.AddHours(-12)) - { - _logger.Trace("Album {0} last updated less than 12 hours ago, should not be refreshed.", album.Title); + if (album.LastInfoSync >= DateTime.UtcNow.AddHours(-12)) + { + _logger.Trace("Album {0} last updated less than 12 hours ago, should not be refreshed.", album.Title); + return false; + } + + if (album.ReleaseDate > DateTime.UtcNow.AddDays(-30)) + { + _logger.Trace("album {0} released less than 30 days ago, should refresh.", album.Title); + return true; + } + + _logger.Trace("Album {0} released long ago and recently refreshed, should not be refreshed.", album.Title); return false; } - - if (album.ReleaseDate > DateTime.UtcNow.AddDays(-30)) + catch (Exception e) { - _logger.Trace("album {0} released less than 30 days ago, should refresh.", album.Title); + _logger.Error(e, "Unable to determine if album should refresh, will try to refresh."); return true; } - - _logger.Trace("Album {0} released long ago and recently refreshed, should not be refreshed.", album.Title); - return false; } } } diff --git a/src/NzbDrone.Core/Music/Utilities/ShouldRefreshArtist.cs b/src/NzbDrone.Core/Music/Utilities/ShouldRefreshArtist.cs index 495b937af..26548d757 100644 --- a/src/NzbDrone.Core/Music/Utilities/ShouldRefreshArtist.cs +++ b/src/NzbDrone.Core/Music/Utilities/ShouldRefreshArtist.cs @@ -22,40 +22,48 @@ namespace NzbDrone.Core.Music public bool ShouldRefresh(Artist artist) { - if (artist.LastInfoSync == null) + try { - _logger.Trace("Artist {0} was just added, should refresh.", artist.Name); - return true; - } + if (artist.LastInfoSync == null) + { + _logger.Trace("Artist {0} was just added, should refresh.", artist.Name); + return true; + } - if (artist.LastInfoSync < DateTime.UtcNow.AddDays(-30)) - { - _logger.Trace("Artist {0} last updated more than 30 days ago, should refresh.", artist.Name); - return true; - } + if (artist.LastInfoSync < DateTime.UtcNow.AddDays(-30)) + { + _logger.Trace("Artist {0} last updated more than 30 days ago, should refresh.", artist.Name); + return true; + } - if (artist.LastInfoSync >= DateTime.UtcNow.AddHours(-12)) - { - _logger.Trace("Artist {0} last updated less than 12 hours ago, should not be refreshed.", artist.Name); + if (artist.LastInfoSync >= DateTime.UtcNow.AddHours(-12)) + { + _logger.Trace("Artist {0} last updated less than 12 hours ago, should not be refreshed.", artist.Name); + return false; + } + + if (artist.Metadata.Value.Status == ArtistStatusType.Continuing && artist.LastInfoSync < DateTime.UtcNow.AddDays(-2)) + { + _logger.Trace("Artist {0} is continuing and has not been refreshed in 2 days, should refresh.", artist.Name); + return true; + } + + var lastAlbum = _albumService.GetAlbumsByArtist(artist.Id).MaxBy(e => e.ReleaseDate); + + if (lastAlbum != null && lastAlbum.ReleaseDate > DateTime.UtcNow.AddDays(-30)) + { + _logger.Trace("Last album in {0} aired less than 30 days ago, should refresh.", artist.Name); + return true; + } + + _logger.Trace("Artist {0} ended long ago, should not be refreshed.", artist.Name); return false; } - - if (artist.Metadata.Value.Status == ArtistStatusType.Continuing && artist.LastInfoSync < DateTime.UtcNow.AddDays(-2)) + catch (Exception e) { - _logger.Trace("Artist {0} is continuing and has not been refreshed in 2 days, should refresh.", artist.Name); + _logger.Error(e, "Unable to determine if artist should refresh, will try to refresh."); return true; } - - var lastAlbum = _albumService.GetAlbumsByArtist(artist.Id).MaxBy(e => e.ReleaseDate); - - if (lastAlbum != null && lastAlbum.ReleaseDate > DateTime.UtcNow.AddDays(-30)) - { - _logger.Trace("Last album in {0} aired less than 30 days ago, should refresh.", artist.Name); - return true; - } - - _logger.Trace("Artist {0} ended long ago, should not be refreshed.", artist.Name); - return false; } } }