Fixed: Only run a complete section update in Plex if all partial updates fail

Closes #773
pull/2/head
Mark McDowall 9 years ago
parent 28a70a0cf1
commit 741dc8f50b

@ -30,7 +30,6 @@ namespace NzbDrone.Core.Notifications.Plex
_logger = logger; _logger = logger;
} }
public void UpdateLibrary(Series series, PlexServerSettings settings) public void UpdateLibrary(Series series, PlexServerSettings settings)
{ {
try try
@ -38,13 +37,11 @@ namespace NzbDrone.Core.Notifications.Plex
_logger.Debug("Sending Update Request to Plex Server"); _logger.Debug("Sending Update Request to Plex Server");
var sections = GetSections(settings); var sections = GetSections(settings);
//TODO: How long should we cache this for?
var partialUpdates = _partialUpdateCache.Get(settings.Host, () => PartialUpdatesAllowed(settings), TimeSpan.FromHours(2)); var partialUpdates = _partialUpdateCache.Get(settings.Host, () => PartialUpdatesAllowed(settings), TimeSpan.FromHours(2));
if (partialUpdates) if (partialUpdates)
{ {
sections.ForEach(s => UpdateSeries(s.Id, series, s.Language, settings)); UpdatePartialSection(series, sections, settings);
} }
else else
@ -116,20 +113,28 @@ namespace NzbDrone.Core.Notifications.Plex
_plexServerProxy.Update(sectionId, settings); _plexServerProxy.Update(sectionId, settings);
} }
private void UpdateSeries(int sectionId, Series series, string language, PlexServerSettings settings) private void UpdatePartialSection(Series series, List<PlexSection> sections, PlexServerSettings settings)
{ {
_logger.Debug("Updating Plex host: {0}, Section: {1}, Series: {2}", settings.Host, sectionId, series); var partiallyUpdated = false;
var metadataId = GetMetadataId(sectionId, series, language, settings); foreach (var section in sections)
{
var metadataId = GetMetadataId(section.Id, series, section.Language, settings);
if (metadataId.HasValue) if (metadataId.HasValue)
{ {
_logger.Debug("Updating Plex host: {0}, Section: {1}, Series: {2}", settings.Host, section.Id, series);
_plexServerProxy.UpdateSeries(metadataId.Value, settings); _plexServerProxy.UpdateSeries(metadataId.Value, settings);
partiallyUpdated = true;
}
} }
else // Only update complete sections if all partial updates failed
if (!partiallyUpdated)
{ {
UpdateSection(sectionId, settings); _logger.Debug("Unable to update partial section, updating all TV sections");
sections.ForEach(s => UpdateSection(s.Id, settings));
} }
} }

Loading…
Cancel
Save