mirror of
https://github.com/Radarr/Radarr
synced 2026-05-08 16:11:04 +02:00
New: Support for new SABnzbd history retention values
Closes #10699 (cherry picked from commit e361f18837d98c089f7dc9c0190221ca8e2cf225)
This commit is contained in:
parent
0fee552074
commit
b845268b3d
3 changed files with 72 additions and 14 deletions
|
|
@ -478,6 +478,37 @@ public void should_set_history_removes_completed_downloads_true(string historyRe
|
||||||
downloadClientInfo.RemovesCompletedDownloads.Should().BeTrue();
|
downloadClientInfo.RemovesCompletedDownloads.Should().BeTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase("all", 0)]
|
||||||
|
[TestCase("days-archive", 15)]
|
||||||
|
[TestCase("days-delete", 15)]
|
||||||
|
public void should_set_history_removes_completed_downloads_false_for_separate_properties(string option, int number)
|
||||||
|
{
|
||||||
|
_config.Misc.history_retention_option = option;
|
||||||
|
_config.Misc.history_retention_number = number;
|
||||||
|
|
||||||
|
var downloadClientInfo = Subject.GetStatus();
|
||||||
|
|
||||||
|
downloadClientInfo.RemovesCompletedDownloads.Should().BeFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase("number-archive", 10)]
|
||||||
|
[TestCase("number-delete", 10)]
|
||||||
|
[TestCase("number-archive", 0)]
|
||||||
|
[TestCase("number-delete", 0)]
|
||||||
|
[TestCase("days-archive", 3)]
|
||||||
|
[TestCase("days-delete", 3)]
|
||||||
|
[TestCase("all-archive", 0)]
|
||||||
|
[TestCase("all-delete", 0)]
|
||||||
|
public void should_set_history_removes_completed_downloads_true_for_separate_properties(string option, int number)
|
||||||
|
{
|
||||||
|
_config.Misc.history_retention_option = option;
|
||||||
|
_config.Misc.history_retention_number = number;
|
||||||
|
|
||||||
|
var downloadClientInfo = Subject.GetStatus();
|
||||||
|
|
||||||
|
downloadClientInfo.RemovesCompletedDownloads.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
[TestCase(@"Y:\sabnzbd\root", @"completed\downloads", @"vv", @"Y:\sabnzbd\root\completed\downloads", @"Y:\sabnzbd\root\completed\downloads\vv")]
|
[TestCase(@"Y:\sabnzbd\root", @"completed\downloads", @"vv", @"Y:\sabnzbd\root\completed\downloads", @"Y:\sabnzbd\root\completed\downloads\vv")]
|
||||||
[TestCase(@"Y:\sabnzbd\root", @"completed", @"vv", @"Y:\sabnzbd\root\completed", @"Y:\sabnzbd\root\completed\vv")]
|
[TestCase(@"Y:\sabnzbd\root", @"completed", @"vv", @"Y:\sabnzbd\root\completed", @"Y:\sabnzbd\root\completed\vv")]
|
||||||
[TestCase(@"/sabnzbd/root", @"completed/downloads", @"vv", @"/sabnzbd/root/completed/downloads", @"/sabnzbd/root/completed/downloads/vv")]
|
[TestCase(@"/sabnzbd/root", @"completed/downloads", @"vv", @"/sabnzbd/root/completed/downloads", @"/sabnzbd/root/completed/downloads/vv")]
|
||||||
|
|
|
||||||
|
|
@ -278,20 +278,7 @@ public override DownloadClientInfo GetStatus()
|
||||||
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, category.FullPath) };
|
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, category.FullPath) };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.Misc.history_retention.IsNullOrWhiteSpace())
|
status.RemovesCompletedDownloads = RemovesCompletedDownloads(config);
|
||||||
{
|
|
||||||
status.RemovesCompletedDownloads = false;
|
|
||||||
}
|
|
||||||
else if (config.Misc.history_retention.EndsWith("d"))
|
|
||||||
{
|
|
||||||
int.TryParse(config.Misc.history_retention.AsSpan(0, config.Misc.history_retention.Length - 1),
|
|
||||||
out var daysRetention);
|
|
||||||
status.RemovesCompletedDownloads = daysRetention < 14;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
status.RemovesCompletedDownloads = config.Misc.history_retention != "0";
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
@ -548,6 +535,44 @@ private bool ContainsCategory(IEnumerable<string> categories, string category)
|
||||||
return categories.Contains(category);
|
return categories.Contains(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool RemovesCompletedDownloads(SabnzbdConfig config)
|
||||||
|
{
|
||||||
|
var retention = config.Misc.history_retention;
|
||||||
|
var option = config.Misc.history_retention_option;
|
||||||
|
var number = config.Misc.history_retention_number;
|
||||||
|
|
||||||
|
switch (option)
|
||||||
|
{
|
||||||
|
case "all":
|
||||||
|
return false;
|
||||||
|
case "number-archive":
|
||||||
|
case "number-delete":
|
||||||
|
return true;
|
||||||
|
case "days-archive":
|
||||||
|
case "days-delete":
|
||||||
|
return number < 14;
|
||||||
|
case "all-archive":
|
||||||
|
case "all-delete":
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Remove these checks once support for SABnzbd < 4.3 is removed
|
||||||
|
|
||||||
|
if (retention.IsNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (retention.EndsWith("d"))
|
||||||
|
{
|
||||||
|
int.TryParse(config.Misc.history_retention.AsSpan(0, config.Misc.history_retention.Length - 1),
|
||||||
|
out var daysRetention);
|
||||||
|
return daysRetention < 14;
|
||||||
|
}
|
||||||
|
|
||||||
|
return retention != "0";
|
||||||
|
}
|
||||||
|
|
||||||
private bool ValidatePath(DownloadClientItem downloadClientItem)
|
private bool ValidatePath(DownloadClientItem downloadClientItem)
|
||||||
{
|
{
|
||||||
var downloadItemOutputPath = downloadClientItem.OutputPath;
|
var downloadItemOutputPath = downloadClientItem.OutputPath;
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ public class SabnzbdConfigMisc
|
||||||
public bool enable_date_sorting { get; set; }
|
public bool enable_date_sorting { get; set; }
|
||||||
public bool pre_check { get; set; }
|
public bool pre_check { get; set; }
|
||||||
public string history_retention { get; set; }
|
public string history_retention { get; set; }
|
||||||
|
public string history_retention_option { get; set; }
|
||||||
|
public int history_retention_number { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SabnzbdCategory
|
public class SabnzbdCategory
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue