Fixed: Sabnzbd downloads with single obfuscated files in nested subdirectories are now handled appropriately.

This commit is contained in:
Taloth Saldono 2014-07-20 00:53:22 +02:00 committed by Mark McDowall
parent 8a18124212
commit e9f39493f4
2 changed files with 30 additions and 11 deletions

View File

@ -283,17 +283,21 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
.Verify(v => v.DownloadNzb(It.IsAny<Stream>(), It.IsAny<String>(), It.IsAny<String>(), (int)SabnzbdPriority.High, It.IsAny<SabnzbdSettings>()), Times.Once()); .Verify(v => v.DownloadNzb(It.IsAny<Stream>(), It.IsAny<String>(), It.IsAny<String>(), (int)SabnzbdPriority.High, It.IsAny<SabnzbdSettings>()), Times.Once());
} }
[Test] [TestCase(@"Droned.S01E01.Pilot.1080p.WEB-DL-DRONE", @"Droned.S01E01_Pilot_1080p_WEB-DL-DRONE.mkv")]
public void should_return_path_to_folder_instead_of_file() [TestCase(@"Droned.S01E01.Pilot.1080p.WEB-DL-DRONE", @"SubDir\Droned.S01E01_Pilot_1080p_WEB-DL-DRONE.mkv")]
[TestCase(@"Droned.S01E01.Pilot.1080p.WEB-DL-DRONE.mkv", @"SubDir\Droned.S01E01_Pilot_1080p_WEB-DL-DRONE.mkv")]
[TestCase(@"Droned.S01E01.Pilot.1080p.WEB-DL-DRONE.mkv", @"SubDir\SubDir\Droned.S01E01_Pilot_1080p_WEB-DL-DRONE.mkv")]
public void should_return_path_to_jobfolder(String title, String storage)
{ {
_completed.Items.First().Storage = @"C:\sorted\Droned.S01E01.Pilot.1080p.WEB-DL-DRONE\Droned.S01E01_Pilot_1080p_WEB-DL-DRONE.mkv".AsOsAgnostic(); _completed.Items.First().Title = title;
_completed.Items.First().Storage = (@"C:\sorted\" + title + @"\" + storage).AsOsAgnostic();
WithQueue(null); WithQueue(null);
WithHistory(_completed); WithHistory(_completed);
var result = Subject.GetItems().Single(); var result = Subject.GetItems().Single();
result.OutputPath.Should().Be(@"C:\sorted\Droned.S01E01.Pilot.1080p.WEB-DL-DRONE".AsOsAgnostic()); result.OutputPath.Should().Be((@"C:\sorted\" + title).AsOsAgnostic());
} }
[Test] [Test]
@ -322,6 +326,19 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
result.OutputPath.Should().Be(@"C:\".AsOsAgnostic()); result.OutputPath.Should().Be(@"C:\".AsOsAgnostic());
} }
[Test]
public void should_not_blow_up_if_storage_doesnt_have_jobfolder()
{
_completed.Items.First().Storage = @"C:\sorted\somewhere\asdfasdf\asdfasdf.mkv".AsOsAgnostic();
WithQueue(null);
WithHistory(_completed);
var result = Subject.GetItems().Single();
result.OutputPath.Should().Be(@"C:\sorted\somewhere\asdfasdf\asdfasdf.mkv".AsOsAgnostic());
}
[TestCase(@"Y:\nzbget\root", @"completed\downloads", @"vv", @"Y:\nzbget\root\completed\downloads\vv")] [TestCase(@"Y:\nzbget\root", @"completed\downloads", @"vv", @"Y:\nzbget\root\completed\downloads\vv")]
[TestCase(@"Y:\nzbget\root", @"completed", @"vv", @"Y:\nzbget\root\completed\vv")] [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/downloads", @"vv", @"/nzbget/root/completed/downloads/vv")]

View File

@ -163,14 +163,16 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
if (!sabHistoryItem.Storage.IsNullOrWhiteSpace()) if (!sabHistoryItem.Storage.IsNullOrWhiteSpace())
{ {
historyItem.OutputPath = sabHistoryItem.Storage;
var parent = sabHistoryItem.Storage.GetParentPath(); var parent = sabHistoryItem.Storage.GetParentPath();
if (parent != null && Path.GetFileName(parent) == sabHistoryItem.Title) while (parent != null)
{ {
historyItem.OutputPath = parent; if (Path.GetFileName(parent) == sabHistoryItem.Title)
} {
else historyItem.OutputPath = parent;
{ }
historyItem.OutputPath = sabHistoryItem.Storage; parent = parent.GetParentPath();
} }
} }