From 7f60f9de5a2f51cbe245a0e4fced0df9c7e58994 Mon Sep 17 00:00:00 2001 From: Roger Far Date: Mon, 27 Apr 2026 21:04:26 -0600 Subject: [PATCH] Cleanup, fixed failing build. --- .../Regression/TorrentDownloadRaceTests.cs | 4 +++- server/RdtClient.Service/Services/Torrents.cs | 7 ++++++- server/RdtClient.Web/Controllers/TorrentsController.cs | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/server/RdtClient.Service.Test/Regression/TorrentDownloadRaceTests.cs b/server/RdtClient.Service.Test/Regression/TorrentDownloadRaceTests.cs index 9c916ab..3218d12 100644 --- a/server/RdtClient.Service.Test/Regression/TorrentDownloadRaceTests.cs +++ b/server/RdtClient.Service.Test/Regression/TorrentDownloadRaceTests.cs @@ -132,6 +132,8 @@ public class TorrentDownloadRaceTests : IAsyncLifetime public Task DisposeAsync() { + SqliteConnection.ClearAllPools(); + if (File.Exists(_databasePath)) { File.Delete(_databasePath); @@ -160,7 +162,7 @@ public class TorrentDownloadRaceTests : IAsyncLifetime var torrentId = Guid.NewGuid(); await using var context = CreateContext(); - context.Torrents.Add(new Torrent + context.Torrents.Add(new() { TorrentId = torrentId, Hash = Guid.NewGuid().ToString("N"), diff --git a/server/RdtClient.Service/Services/Torrents.cs b/server/RdtClient.Service/Services/Torrents.cs index 6509e58..b0eed08 100644 --- a/server/RdtClient.Service/Services/Torrents.cs +++ b/server/RdtClient.Service/Services/Torrents.cs @@ -3,6 +3,7 @@ using System.IO.Abstractions; using System.Security.Cryptography; using System.Text; using System.Text.Json; +using System.Text.Json.Serialization; using System.Xml; using System.Xml.Linq; using Microsoft.Extensions.Logging; @@ -37,6 +38,11 @@ public class Torrents( private static readonly SemaphoreSlim TorrentResetLock = new(1, 1); + private static readonly JsonSerializerOptions JsonSerializerOptions = new() + { + ReferenceHandler = ReferenceHandler.IgnoreCycles + }; + private IDebridClient DebridClient { get @@ -609,7 +615,6 @@ public class Torrents( return unrestrictedLink; } - /// public async Task RetrieveFileName(Guid downloadId) { var download = await downloads.GetById(downloadId) ?? throw new($"Download with ID {downloadId} not found"); diff --git a/server/RdtClient.Web/Controllers/TorrentsController.cs b/server/RdtClient.Web/Controllers/TorrentsController.cs index 9cc1fa1..b6eb5a7 100644 --- a/server/RdtClient.Web/Controllers/TorrentsController.cs +++ b/server/RdtClient.Web/Controllers/TorrentsController.cs @@ -388,7 +388,7 @@ public class TorrentsController(ILogger logger, Torrents tor private static async Task ReadFormFileBytes(IFormFile file) { await using var fileStream = file.OpenReadStream(); - await using var memoryStream = file.Length > 0 && file.Length <= Int32.MaxValue ? new MemoryStream((Int32)file.Length) : new MemoryStream(); + await using var memoryStream = file.Length is > 0 and <= Int32.MaxValue ? new((Int32)file.Length) : new MemoryStream(); await fileStream.CopyToAsync(memoryStream);