1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

Fixed issue with a relative complete dir in sabnzbd.

This commit is contained in:
Taloth Saldono 2014-07-12 00:16:49 +02:00
parent 2a0f461135
commit df0082c077
3 changed files with 46 additions and 10 deletions

View File

@ -23,6 +23,7 @@ public class SabnzbdFixture : DownloadClientFixtureBase<Sabnzbd>
private SabnzbdQueue _queued; private SabnzbdQueue _queued;
private SabnzbdHistory _failed; private SabnzbdHistory _failed;
private SabnzbdHistory _completed; private SabnzbdHistory _completed;
private SabnzbdConfig _config;
[SetUp] [SetUp]
public void Setup() public void Setup()
@ -40,6 +41,7 @@ public void Setup()
}; };
_queued = new SabnzbdQueue _queued = new SabnzbdQueue
{ {
DefaultRootFolder = @"Y:\nzbget\root".AsOsAgnostic(),
Paused = false, Paused = false,
Items = new List<SabnzbdQueueItem>() Items = new List<SabnzbdQueueItem>()
{ {
@ -87,19 +89,21 @@ public void Setup()
} }
}; };
Mocker.GetMock<ISabnzbdProxy>() _config = new SabnzbdConfig
.Setup(s => s.GetConfig(It.IsAny<SabnzbdSettings>()))
.Returns(new SabnzbdConfig
{ {
Misc = new SabnzbdConfigMisc Misc = new SabnzbdConfigMisc
{ {
complete_dir = "/remote/mount/" complete_dir = @"/remote/mount"
}, },
Categories = new List<SabnzbdCategory> Categories = new List<SabnzbdCategory>
{ {
new SabnzbdCategory { Name = "tv", Dir = "vv" } new SabnzbdCategory { Name = "tv", Dir = "vv" }
} }
}); };
Mocker.GetMock<ISabnzbdProxy>()
.Setup(s => s.GetConfig(It.IsAny<SabnzbdSettings>()))
.Returns(_config);
} }
protected void WithMountPoint(String mountPath) protected void WithMountPoint(String mountPath)
@ -129,7 +133,11 @@ protected virtual void WithQueue(SabnzbdQueue queue)
{ {
if (queue == null) if (queue == null)
{ {
queue = new SabnzbdQueue() { Items = new List<SabnzbdQueueItem>() }; queue = new SabnzbdQueue()
{
DefaultRootFolder = _queued.DefaultRootFolder,
Items = new List<SabnzbdQueueItem>()
};
} }
Mocker.GetMock<ISabnzbdProxy>() Mocker.GetMock<ISabnzbdProxy>()
@ -314,14 +322,23 @@ public void should_not_blow_up_if_storage_is_drive_root()
result.OutputPath.Should().Be(@"C:\".AsOsAgnostic()); result.OutputPath.Should().Be(@"C:\".AsOsAgnostic());
} }
[Test] [TestCase(@"Y:\nzbget\root", @"completed\downloads", @"vv", @"Y:\nzbget\root\completed\downloads\vv")]
public void should_return_status_with_outputdir() [TestCase(@"Y:\nzbget\root", @"completed", @"vv", @"Y:\nzbget\root\completed\vv")]
[TestCase(@"/nzbget/root", @"completed/downloads", @"vv", @"/nzbget/root/completed/downloads/vv")]
[TestCase(@"/nzbget/root", @"completed", @"vv", @"/nzbget/root/completed/vv")]
public void should_return_status_with_outputdir(String rootFolder, String completeDir, String categoryDir, String expectedDir)
{ {
_queued.DefaultRootFolder = rootFolder;
_config.Misc.complete_dir = completeDir;
_config.Categories.First().Dir = categoryDir;
WithQueue(null);
var result = Subject.GetStatus(); var result = Subject.GetStatus();
result.IsLocalhost.Should().BeTrue(); result.IsLocalhost.Should().BeTrue();
result.OutputRootFolders.Should().NotBeNull(); result.OutputRootFolders.Should().NotBeNull();
result.OutputRootFolders.First().Should().Be(@"/remote/mount/vv"); result.OutputRootFolders.First().Should().Be(expectedDir);
} }
[Test] [Test]
@ -329,6 +346,8 @@ public void should_return_status_with_mounted_outputdir()
{ {
WithMountPoint(@"O:\mymount".AsOsAgnostic()); WithMountPoint(@"O:\mymount".AsOsAgnostic());
WithQueue(null);
var result = Subject.GetStatus(); var result = Subject.GetStatus();
result.IsLocalhost.Should().BeTrue(); result.IsLocalhost.Should().BeTrue();

View File

@ -236,6 +236,20 @@ protected IEnumerable<SabnzbdCategory> GetCategories(SabnzbdConfig config)
{ {
var completeDir = config.Misc.complete_dir.TrimEnd('\\', '/'); var completeDir = config.Misc.complete_dir.TrimEnd('\\', '/');
if (!completeDir.StartsWith("/") && !completeDir.StartsWith("\\") && !completeDir.Contains(':'))
{
var queue = _proxy.GetQueue(0, 1, Settings);
if (queue.DefaultRootFolder.StartsWith("/"))
{
completeDir = queue.DefaultRootFolder + "/" + completeDir;
}
else
{
completeDir = queue.DefaultRootFolder + "\\" + completeDir;
}
}
foreach (var category in config.Categories) foreach (var category in config.Categories)
{ {
var relativeDir = category.Dir.TrimEnd('*'); var relativeDir = category.Dir.TrimEnd('*');

View File

@ -5,6 +5,9 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
{ {
public class SabnzbdQueue public class SabnzbdQueue
{ {
[JsonProperty(PropertyName = "my_home")]
public string DefaultRootFolder { get; set; }
public bool Paused { get; set; } public bool Paused { get; set; }
[JsonProperty(PropertyName = "slots")] [JsonProperty(PropertyName = "slots")]