|
|
|
@ -208,27 +208,44 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
|
|
|
|
public override String RetryDownload(String id)
|
|
|
|
|
{
|
|
|
|
|
// Sabnzbd changed the nzo_id for retried downloads without reporting it back to us. We need to try to determine the new ID.
|
|
|
|
|
// Check both the queue and history because sometimes SAB keeps item in history to retry post processing (depends on failure reason)
|
|
|
|
|
|
|
|
|
|
var history = GetHistory().Where(v => v.DownloadClientId == id).ToList();
|
|
|
|
|
var currentHistory = GetHistory().ToList();
|
|
|
|
|
var currentHistoryItems = currentHistory.Where(v => v.DownloadClientId == id).ToList();
|
|
|
|
|
|
|
|
|
|
_proxy.RetryDownload(id, Settings);
|
|
|
|
|
|
|
|
|
|
if (history.Count() != 1)
|
|
|
|
|
if (currentHistoryItems.Count != 1)
|
|
|
|
|
{
|
|
|
|
|
_logger.Warn("History item missing. Couldn't get the new nzoid.");
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var currentHistoryItem = currentHistoryItems.First();
|
|
|
|
|
var otherItemsWithSameTitle = currentHistory.Where(h => h.Title == currentHistoryItem.Title &&
|
|
|
|
|
h.DownloadClientId != currentHistoryItem.DownloadClientId).ToList();
|
|
|
|
|
|
|
|
|
|
_proxy.RetryDownload(id, Settings);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
|
{
|
|
|
|
|
var queue = GetQueue().Where(v => v.Category == history.First().Category && v.Title == history.First().Title).ToList();
|
|
|
|
|
var queue = GetQueue().Where(v => v.Category == currentHistoryItem.Category &&
|
|
|
|
|
v.Title == currentHistoryItem.Title).ToList();
|
|
|
|
|
|
|
|
|
|
if (queue.Count() == 1)
|
|
|
|
|
var history = GetHistory().Where(v => v.Category == currentHistoryItem.Category &&
|
|
|
|
|
v.Title == currentHistoryItem.Title &&
|
|
|
|
|
otherItemsWithSameTitle.Select(h => h.DownloadClientId)
|
|
|
|
|
.Contains(v.DownloadClientId)).ToList();
|
|
|
|
|
|
|
|
|
|
if (queue.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
return queue.First().DownloadClientId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (queue.Count() > 2)
|
|
|
|
|
if (history.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
return history.First().DownloadClientId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (queue.Count > 1 || history.Count > 1)
|
|
|
|
|
{
|
|
|
|
|
_logger.Warn("Multiple items with the correct title. Couldn't get the new nzoid.");
|
|
|
|
|
return id;
|
|
|
|
|