Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.idea.CatBox.NET/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/CatBox.NET/CatBox.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<Version>1.0</Version>
<Version>1.1</Version>
<Authors>Chase Redmon, Kuinox, Adam Sears</Authors>
<Description>CatBox.NET is a .NET Library for uploading files, URLs, and modifying albums on CatBox.moe</Description>
<PackageProjectUrl>https://github.com/ChaseDRedmon/CatBox.NET</PackageProjectUrl>
Expand All @@ -15,6 +15,7 @@
<PackageLicenseUrl>https://github.com/ChaseDRedmon/CatBox.NET/blob/main/license.txt</PackageLicenseUrl>
<PackageReleaseNotes>Fix required description field on create album endpoint. Description is optional when creating an endpoint.</PackageReleaseNotes>
<TargetFramework>net10.0</TargetFramework>
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/CatBox.NET/CatBox.NET.csproj.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/Daemon/ConfigureAwaitAnalysisMode/@EntryValue">Library</s:String></wpf:ResourceDictionary>
27 changes: 24 additions & 3 deletions src/CatBox.NET/CatBoxServices.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using CatBox.NET.Client;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using CatBox.NET.Client;
using CatBox.NET.Exceptions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Http.Resilience;
Expand Down Expand Up @@ -30,7 +32,7 @@ public IServiceCollection AddCatBoxServices(Action<CatboxOptions> setupAction)
return services;
}

private IServiceCollection AddHttpClientWithMessageHandler<TInterface, TImplementation>()
private IServiceCollection AddHttpClientWithMessageHandler<TInterface, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>()
where TInterface : class
where TImplementation : class, TInterface
{
Expand All @@ -48,8 +50,27 @@ private IServiceCollection AddHttpClientWithMessageHandler<TInterface, TImplemen
BackoffType = DelayBackoffType.Exponential,
UseJitter = true,
Delay = TimeSpan.FromSeconds(5),
MaxRetryAttempts = 5
MaxRetryAttempts = 5,
ShouldHandle = args =>
{
// Don't retry custom CatBox exceptions - these are client errors (4xx)
// Our exceptions inherit from Exception, not HttpRequestException
if (args.Outcome.Exception is not null and not HttpRequestException)
return ValueTask.FromResult(false);

// Retry HttpRequestException (network failures, timeouts)
if (args.Outcome.Exception is HttpRequestException)
return ValueTask.FromResult(true);

// Retry 5xx server errors
if (args.Outcome.Result is { } response)
return ValueTask.FromResult(response.StatusCode >= HttpStatusCode.InternalServerError);

return ValueTask.FromResult(false);
}
};


});

return services;
Expand Down
7 changes: 6 additions & 1 deletion src/CatBox.NET/CatboxOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ public sealed record CatboxOptions
/// URL for the catbox.moe domain
/// </summary>
public Uri? CatBoxUrl { get; set; }


/// <summary>
/// Base URL for downloading CatBox files (default: https://files.catbox.moe/)
/// </summary>
public Uri CatBoxFilesUrl { get; set; } = new("https://files.catbox.moe/");

/// <summary>
/// URL for the litterbox.moe domain
/// </summary>
Expand Down
Loading
Loading