mirror of
https://github.com/Sonarr/Sonarr
synced 2026-05-08 04:50:56 +02:00
Merge 66ef72712a into bf5d48c76a
This commit is contained in:
commit
6bc67fb809
2 changed files with 21 additions and 3 deletions
|
|
@ -40,9 +40,13 @@ public void MarkAsFailed(int historyId, string message, string source = null, bo
|
|||
|
||||
if (downloadId.IsNullOrWhiteSpace())
|
||||
{
|
||||
PublishDownloadFailedEvent(history, new List<int> { history.EpisodeId }, message, source, skipRedownload: skipRedownload);
|
||||
if (history.EventType == EpisodeHistoryEventType.Grabbed)
|
||||
{
|
||||
PublishDownloadFailedEvent(history, new List<int> { history.EpisodeId }, message, source, skipRedownload: skipRedownload);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
throw new InvalidOperationException("Unable to mark download as failed, history item was not grabbed and has no download ID");
|
||||
}
|
||||
|
||||
var grabbedHistory = new List<EpisodeHistory>();
|
||||
|
|
@ -57,7 +61,12 @@ public void MarkAsFailed(int historyId, string message, string source = null, bo
|
|||
grabbedHistory.AddRange(GetGrabbedHistory(downloadId));
|
||||
grabbedHistory = grabbedHistory.DistinctBy(h => h.Id).ToList();
|
||||
|
||||
PublishDownloadFailedEvent(history, GetEpisodeIds(grabbedHistory), message, source);
|
||||
if (grabbedHistory.Any())
|
||||
{
|
||||
PublishDownloadFailedEvent(grabbedHistory.First(), GetEpisodeIds(grabbedHistory), message, source);
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("Unable to mark download as failed, no grabbed history available");
|
||||
}
|
||||
|
||||
public void MarkAsFailed(TrackedDownload trackedDownload, string message, string source = null, bool skipRedownload = false)
|
||||
|
|
@ -68,6 +77,8 @@ public void MarkAsFailed(TrackedDownload trackedDownload, string message, string
|
|||
{
|
||||
PublishDownloadFailedEvent(history.First(), GetEpisodeIds(history), message ?? "Manually marked as failed", source, trackedDownload, skipRedownload: skipRedownload);
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("Unable to mark download as failed, no grabbed history available");
|
||||
}
|
||||
|
||||
public void Check(TrackedDownload trackedDownload)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Data.SQLite;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -76,6 +77,12 @@ public async Task HandleException(HttpContext context)
|
|||
|
||||
_logger.Error(sqLiteException, "[{0} {1}]", context.Request.Method, context.Request.Path);
|
||||
}
|
||||
else if (exception is InvalidOperationException invalidOperationException)
|
||||
{
|
||||
_logger.Warn(invalidOperationException, "[{0} {1}]", context.Request.Method, context.Request.Path);
|
||||
|
||||
statusCode = HttpStatusCode.BadRequest;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Fatal(exception, "Request Failed. {0} {1}", context.Request.Method, context.Request.Path);
|
||||
|
|
|
|||
Loading…
Reference in a new issue