refactored names; fixed return values for hard links service

This commit is contained in:
Flaminel
2025-02-22 00:30:42 +02:00
parent 9b68792ea9
commit 1ad07b1f51
15 changed files with 115 additions and 95 deletions
@@ -266,7 +266,7 @@ public class DelugeService : DownloadService, IDelugeService
}
}
public override Task ChangeCategoryForNoHardlinksAsync(List<object> downloads, HashSet<string> excludedHashes)
public override Task ChangeCategoryForNoHardLinksAsync(List<object> downloads, HashSet<string> excludedHashes)
{
throw new NotImplementedException();
}
@@ -87,7 +87,7 @@ public abstract class DownloadService : IDownloadService
public abstract Task CleanDownloads(List<object> downloads, List<CleanCategory> categoriesToClean, HashSet<string> excludedHashes);
/// <inheritdoc/>
public abstract Task ChangeCategoryForNoHardlinksAsync(List<object> downloads, HashSet<string> excludedHashes);
public abstract Task ChangeCategoryForNoHardLinksAsync(List<object> downloads, HashSet<string> excludedHashes);
protected void ResetStrikesOnProgress(string hash, long downloaded)
{
@@ -68,7 +68,7 @@ public class DummyDownloadService : DownloadService
throw new NotImplementedException();
}
public override Task ChangeCategoryForNoHardlinksAsync(List<object> downloads, HashSet<string> excludedHashes)
public override Task ChangeCategoryForNoHardLinksAsync(List<object> downloads, HashSet<string> excludedHashes)
{
throw new NotImplementedException();
}
@@ -53,7 +53,7 @@ public interface IDownloadService : IDisposable
/// </summary>
/// <param name="downloads">The downloads to change.</param>
/// <param name="excludedHashes"></param>
Task ChangeCategoryForNoHardlinksAsync(List<object> downloads, HashSet<string> excludedHashes);
Task ChangeCategoryForNoHardLinksAsync(List<object> downloads, HashSet<string> excludedHashes);
/// <summary>
/// Deletes a download item.
@@ -5,6 +5,7 @@ using Common.Configuration.ContentBlocker;
using Common.Configuration.DownloadCleaner;
using Common.Configuration.DownloadClient;
using Common.Configuration.QueueCleaner;
using Common.Exceptions;
using Common.Helpers;
using Domain.Enums;
using Infrastructure.Interceptors;
@@ -298,20 +299,26 @@ public class QBitService : DownloadService, IQBitService
}
}
public override async Task ChangeCategoryForNoHardlinksAsync(List<object> downloads, HashSet<string> excludedHashes)
public override async Task ChangeCategoryForNoHardLinksAsync(List<object> downloads, HashSet<string> excludedHashes)
{
if (_downloadCleanerConfig.IgnoreRootDir)
{
// TODO call this only if Unix
downloads
.Cast<TorrentInfo>()
.GroupBy(x => x.SavePath)
.GroupBy(x => Path.GetPathRoot(x.SavePath))
.Select(x => x.Key)
.ToList()
.ForEach(x => _hardlinkFileService.PopulateInodeCounts(x));
.ForEach(x =>
{
if (!Directory.Exists(x))
{
throw new ValidationException($"directory \"{x}\" does not exist");
}
_hardLinkFileService.PopulateFileCounts(x);
});
}
// TODO account for cross-seed
foreach (TorrentInfo download in downloads)
{
IReadOnlyList<TorrentContent>? files = await _client.GetTorrentContentsAsync(download.Hash);
@@ -343,7 +350,7 @@ public class QBitService : DownloadService, IQBitService
: download.SavePath, file.Name
);
long hardlinkCount = _hardlinkFileService.GetHardLinkCount(filePath, _downloadCleanerConfig.IgnoreRootDir);
long hardlinkCount = _hardLinkFileService.GetHardLinkCount(filePath, _downloadCleanerConfig.IgnoreRootDir);
if (hardlinkCount < 0)
{
@@ -364,7 +371,7 @@ public class QBitService : DownloadService, IQBitService
continue;
}
_logger.LogInformation("no hardlinks found | changing category for {name}", download.Name);
_logger.LogInformation("changing category for {name}", download.Name);
await ((QBitService)Proxy).ChangeCategory(download.Hash, _downloadCleanerConfig.NoHardlinksCategory);
await _notifier.NotifyCategoryChanged(download.Category, _downloadCleanerConfig.NoHardlinksCategory);
@@ -289,7 +289,7 @@ public class TransmissionService : DownloadService, ITransmissionService
}
}
public override Task ChangeCategoryForNoHardlinksAsync(List<object> downloads, HashSet<string> excludedHashes)
public override Task ChangeCategoryForNoHardLinksAsync(List<object> downloads, HashSet<string> excludedHashes)
{
throw new NotImplementedException();
}