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);