Fixed potential issue with duplicate categories.
This commit is contained in:
parent
a8dc196dfe
commit
732e8d9691
1 changed files with 24 additions and 14 deletions
|
|
@ -198,6 +198,7 @@ namespace RdtClient.Service.Services
|
||||||
public String AppDefaultSavePath()
|
public String AppDefaultSavePath()
|
||||||
{
|
{
|
||||||
var downloadPath = Settings.Get.MappedPath;
|
var downloadPath = Settings.Get.MappedPath;
|
||||||
|
|
||||||
downloadPath = downloadPath.TrimEnd('\\')
|
downloadPath = downloadPath.TrimEnd('\\')
|
||||||
.TrimEnd('/');
|
.TrimEnd('/');
|
||||||
|
|
||||||
|
|
@ -215,6 +216,7 @@ namespace RdtClient.Service.Services
|
||||||
var torrents = await _torrents.Get();
|
var torrents = await _torrents.Get();
|
||||||
|
|
||||||
var prio = 0;
|
var prio = 0;
|
||||||
|
|
||||||
foreach (var torrent in torrents)
|
foreach (var torrent in torrents)
|
||||||
{
|
{
|
||||||
var downloadPath = savePath;
|
var downloadPath = savePath;
|
||||||
|
|
@ -311,6 +313,7 @@ namespace RdtClient.Service.Services
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IList<TorrentFileItem>> TorrentFileContents(String hash)
|
public async Task<IList<TorrentFileItem>> TorrentFileContents(String hash)
|
||||||
{
|
{
|
||||||
var results = new List<TorrentFileItem>();
|
var results = new List<TorrentFileItem>();
|
||||||
|
|
@ -439,10 +442,11 @@ namespace RdtClient.Service.Services
|
||||||
|
|
||||||
var torrentsToGroup = torrents.Where(m => !String.IsNullOrWhiteSpace(m.Category))
|
var torrentsToGroup = torrents.Where(m => !String.IsNullOrWhiteSpace(m.Category))
|
||||||
.Select(m => m.Category.ToLower())
|
.Select(m => m.Category.ToLower())
|
||||||
.Distinct()
|
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var categories = Settings.Get.Categories.Split(",", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Distinct();
|
var categories = Settings.Get
|
||||||
|
.Categories
|
||||||
|
.Split(",", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||||
|
|
||||||
torrentsToGroup.AddRange(categories);
|
torrentsToGroup.AddRange(categories);
|
||||||
|
|
||||||
|
|
@ -450,7 +454,8 @@ namespace RdtClient.Service.Services
|
||||||
|
|
||||||
if (torrentsToGroup.Count > 0)
|
if (torrentsToGroup.Count > 0)
|
||||||
{
|
{
|
||||||
results = torrentsToGroup.ToDictionary(m => m,
|
results = torrentsToGroup.Distinct(StringComparer.CurrentCultureIgnoreCase)
|
||||||
|
.ToDictionary(m => m,
|
||||||
m => new TorrentCategory
|
m => new TorrentCategory
|
||||||
{
|
{
|
||||||
Name = m,
|
Name = m,
|
||||||
|
|
@ -471,7 +476,10 @@ namespace RdtClient.Service.Services
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var categoryList = categoriesSetting.Split(",", StringSplitOptions.RemoveEmptyEntries).Distinct().ToList();
|
var categoryList = categoriesSetting
|
||||||
|
.Split(",", StringSplitOptions.RemoveEmptyEntries)
|
||||||
|
.Distinct(StringComparer.CurrentCultureIgnoreCase)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
if (!categoryList.Contains(category))
|
if (!categoryList.Contains(category))
|
||||||
{
|
{
|
||||||
|
|
@ -493,7 +501,9 @@ namespace RdtClient.Service.Services
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var categoryList = categoriesSetting.Split(",", StringSplitOptions.RemoveEmptyEntries).Distinct().ToList();
|
var categoryList = categoriesSetting.Split(",", StringSplitOptions.RemoveEmptyEntries)
|
||||||
|
.Distinct(StringComparer.CurrentCultureIgnoreCase)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
categoryList = categoryList.Where(m => m != category).ToList();
|
categoryList = categoryList.Where(m => m != category).ToList();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue