Merge branch 'main' into add_cleanup_on_no_hardlinks

This commit is contained in:
Flaminel
2025-03-26 00:28:59 +02:00
2 changed files with 5 additions and 28 deletions
+1 -1
View File
@@ -13,7 +13,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="FLM.QBittorrent" Version="1.0.0" /> <PackageReference Include="FLM.QBittorrent" Version="1.0.0" />
<PackageReference Include="FLM.Transmission" Version="1.0.2" /> <PackageReference Include="FLM.Transmission" Version="1.0.3" />
<PackageReference Include="Mapster" Version="7.4.0" /> <PackageReference Include="Mapster" Version="7.4.0" />
<PackageReference Include="MassTransit" Version="8.3.6" /> <PackageReference Include="MassTransit" Version="8.3.6" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.2" /> <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.2" />
@@ -28,7 +28,6 @@ public class TransmissionService : DownloadService, ITransmissionService
{ {
private readonly TransmissionConfig _config; private readonly TransmissionConfig _config;
private readonly Client _client; private readonly Client _client;
private TorrentInfo[]? _torrentsCache;
private static readonly string[] Fields = private static readonly string[] Fields =
[ [
@@ -535,30 +534,8 @@ public class TransmissionService : DownloadService, ITransmissionService
return (await StrikeAndCheckLimit(torrent.HashString!, torrent.Name!, StrikeType.Stalled), DeleteReason.Stalled); return (await StrikeAndCheckLimit(torrent.HashString!, torrent.Name!, StrikeType.Stalled), DeleteReason.Stalled);
} }
private async Task<TorrentInfo?> GetTorrentAsync(string hash) private async Task<TorrentInfo?> GetTorrentAsync(string hash) =>
{ (await _client.TorrentGetAsync(Fields, hash))
TorrentInfo? torrent = _torrentsCache? ?.Torrents
.FirstOrDefault(x => x.HashString.Equals(hash, StringComparison.InvariantCultureIgnoreCase)); ?.FirstOrDefault();
if (_torrentsCache is null || torrent is null)
{
// refresh cache
_torrentsCache = (await _client.TorrentGetAsync(Fields))
?.Torrents;
}
if (_torrentsCache?.Length is null or 0)
{
_logger.LogDebug("could not list torrents | {url}", _config.Url);
}
torrent = _torrentsCache?.FirstOrDefault(x => x.HashString.Equals(hash, StringComparison.InvariantCultureIgnoreCase));
if (torrent is null)
{
_logger.LogDebug("could not find torrent | {hash} | {url}", hash, _config.Url);
}
return torrent;
}
} }