Skip to content

Usenet streaming with a WebDAV server and a SABnzbd-compatible API

C#

Do not retry queue downloads on unknown errors.

nzbdav-dev189c8db1bd96
diff --git a/backend/Extensions/ExceptionExtensions.cs b/backend/Extensions/ExceptionExtensions.cs
index d6c7f2e0..bd811f4f 100644
--- a/backend/Extensions/ExceptionExtensions.cs
+++ b/backend/Extensions/ExceptionExtensions.cs
@@ -4,6 +4,11 @@ namespace NzbWebDAV.Extensions;
public static class ExceptionExtensions
{
+ public static bool IsRetryableDownloadException(this Exception exception)
+ {
+ return exception is RetryableDownloadException;
+ }
+
public static bool IsNonRetryableDownloadException(this Exception exception)
{
return exception is NonRetryableDownloadException
diff --git a/backend/Queue/QueueItemProcessor.cs b/backend/Queue/QueueItemProcessor.cs
index 165d1b2b..2b2b1d41 100644
--- a/backend/Queue/QueueItemProcessor.cs
+++ b/backend/Queue/QueueItemProcessor.cs
@@ -50,26 +50,11 @@ public class QueueItemProcessor(
dbClient.Ctx.ChangeTracker.Clear();
}
- // when non-retryable errors are encountered
- // we must still remove the queue-item and add
- // it to the history as a failed job.
- catch (Exception e) when (e.IsNonRetryableDownloadException())
- {
- try
- {
- await MarkQueueItemCompleted(startTime, error: e.Message);
- }
- catch (Exception ex)
- {
- Log.Error(e, ex.Message);
- }
- }
-
- // when an unknown error is encountered
+ // when a retryable error is encountered
// let's not remove the item from the queue
// to give it a chance to retry. Simply
// log the error and retry in a minute.
- catch (Exception e)
+ catch (Exception e) when (e.IsRetryableDownloadException())
{
try
{
@@ -86,6 +71,21 @@ public class QueueItemProcessor(
Log.Error(ex, ex.Message);
}
}
+
+ // when any other error is encountered,
+ // we must still remove the queue-item and add
+ // it to the history as a failed job.
+ catch (Exception e)
+ {
+ try
+ {
+ await MarkQueueItemCompleted(startTime, error: e.Message);
+ }
+ catch (Exception ex)
+ {
+ Log.Error(e, ex.Message);
+ }
+ }
}
private async Task ProcessQueueItemAsync(DateTime startTime)