fixed categories not being filtered when fetching downloads; fixed inconsistent var naming

This commit is contained in:
Flaminel
2025-02-22 02:27:48 +02:00
parent bd81f2ffca
commit c65c85a0c5
4 changed files with 22 additions and 17 deletions
@@ -65,18 +65,18 @@ public sealed class DownloadCleaner : GenericHandler
List<object>? downloadsToBeCleaned = await _downloadService.GetDownloadsToBeCleanedAsync(_config.Categories);
List<object>? downloadsToChangeCategory = null;
if (!string.IsNullOrEmpty(_config.NoHardlinksCategory) && _config.HardlinkCategories?.Count > 0)
if (!string.IsNullOrEmpty(_config.NoHardLinksCategory) && _config.NoHardLinksCategories?.Count > 0)
{
if (!_hardLinkCategoryCreated)
{
_logger.LogTrace("creating category {cat}", _config.NoHardlinksCategory);
_logger.LogTrace("creating category {cat}", _config.NoHardLinksCategory);
await _downloadService.CreateCategoryAsync(_config.NoHardlinksCategory);
await _downloadService.CreateCategoryAsync(_config.NoHardLinksCategory);
_hardLinkCategoryCreated = true;
}
_logger.LogTrace("getting downloads to change category");
downloadsToChangeCategory = await _downloadService.GetDownloadsToChangeCategoryAsync(_config.HardlinkCategories);
downloadsToChangeCategory = await _downloadService.GetDownloadsToChangeCategoryAsync(_config.NoHardLinksCategories);
}
bool hasDownloadsToClean = downloadsToBeCleaned?.Count > 0;
@@ -226,6 +226,7 @@ public class QBitService : DownloadService, IQBitService
Filter = TorrentListFilter.Seeding
}))
?.Where(x => !string.IsNullOrEmpty(x.Hash))
.Where(x => categories.Any(cat => cat.Equals(x.Category, StringComparison.InvariantCultureIgnoreCase)))
.Cast<object>()
.ToList();
}
@@ -313,7 +314,7 @@ public class QBitService : DownloadService, IQBitService
public override async Task ChangeCategoryForNoHardLinksAsync(List<object> downloads, HashSet<string> excludedHashes)
{
if (_downloadCleanerConfig.IgnoreRootDir)
if (_downloadCleanerConfig.NoHardLinksIgnoreRootDir)
{
downloads
.Cast<TorrentInfo>()
@@ -365,6 +366,8 @@ public class QBitService : DownloadService, IQBitService
continue;
}
ContextProvider.Set("downloadName", download.Name);
ContextProvider.Set("hash", download.Hash);
bool hasHardlinks = false;
foreach (TorrentContent file in files)
@@ -380,7 +383,7 @@ public class QBitService : DownloadService, IQBitService
: download.SavePath, file.Name
);
long hardlinkCount = _hardLinkFileService.GetHardLinkCount(filePath, _downloadCleanerConfig.IgnoreRootDir);
long hardlinkCount = _hardLinkFileService.GetHardLinkCount(filePath, _downloadCleanerConfig.NoHardLinksIgnoreRootDir);
if (hardlinkCount < 0)
{
@@ -403,8 +406,8 @@ public class QBitService : DownloadService, IQBitService
_logger.LogInformation("changing category for {name}", download.Name);
await ((QBitService)Proxy).ChangeCategory(download.Hash, _downloadCleanerConfig.NoHardlinksCategory);
await _notifier.NotifyCategoryChanged(download.Category, _downloadCleanerConfig.NoHardlinksCategory);
await ((QBitService)Proxy).ChangeCategory(download.Hash, _downloadCleanerConfig.NoHardLinksCategory);
await _notifier.NotifyCategoryChanged(download.Category, _downloadCleanerConfig.NoHardLinksCategory);
}
}