Fixed: Some timing issues in Sabnzbd RetryDownload logic.

This commit is contained in:
Taloth Saldono 2014-07-28 01:13:39 +02:00
parent 174a209c66
commit e867548ec3
2 changed files with 21 additions and 7 deletions

View File

@ -239,17 +239,31 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
if (history.Count() != 1)
{
_logger.Debug("History item missing. Couldn't get the new nzoid.");
return id;
}
var queue = GetQueue().Where(v => v.Category == history.First().Category && v.Title == history.First().Title).ToList();
if (queue.Count() != 1)
var queue = new List<DownloadClientItem>();
for (int i = 0; i < 3; i++)
{
queue = GetQueue().Where(v => v.Category == history.First().Category && v.Title == history.First().Title).ToList();
if (queue.Count() == 1)
{
return queue.First().DownloadClientId;
}
if (queue.Count() > 2)
{
_logger.Debug("Multiple items with the correct title. Couldn't get the new nzoid.");
return id;
}
return queue.First().DownloadClientId;
System.Threading.Thread.Sleep(500);
}
_logger.Debug("No items with the correct title. Couldn't get the new nzoid.");
return id;
}
protected IEnumerable<SabnzbdCategory> GetCategories(SabnzbdConfig config)

View File

@ -147,7 +147,7 @@ namespace NzbDrone.Core.Download
State = TrackedDownloadState.Unknown
};
_logger.Trace("Started tracking download from history: {0}: {1}", trackedDownload.TrackingId, downloadItem.Title);
_logger.Debug("Started tracking download from history: {0}: {1}", trackedDownload.TrackingId, downloadItem.Title);
stateChanged = true;
}
@ -167,7 +167,7 @@ namespace NzbDrone.Core.Download
_logger.Debug("Item removed from download client by user: {0}: {1}", downloadItem.TrackingId, downloadItem.DownloadItem.Title);
}
_logger.Trace("Stopped tracking download: {0}: {1}", downloadItem.TrackingId, downloadItem.DownloadItem.Title);
_logger.Debug("Stopped tracking download: {0}: {1}", downloadItem.TrackingId, downloadItem.DownloadItem.Title);
}
_trackedDownloadCache.Set("tracked", newTrackedDownloads.Values.ToArray());