1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-30 19:56:54 +00:00

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());
}
[Test]
public void should_return_path_to_folder_instead_of_file()
[TestCase(@"Droned.S01E01.Pilot.1080p.WEB-DL-DRONE", @"Droned.S01E01_Pilot_1080p_WEB-DL-DRONE.mkv")]
[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);
WithHistory(_completed);
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]
@ -322,6 +326,19 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
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", @"vv", @"Y:\nzbget\root\completed\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())
{
historyItem.OutputPath = sabHistoryItem.Storage;
var parent = sabHistoryItem.Storage.GetParentPath();
if (parent != null && Path.GetFileName(parent) == sabHistoryItem.Title)
while (parent != null)
{
historyItem.OutputPath = parent;
}
else
{
historyItem.OutputPath = sabHistoryItem.Storage;
if (Path.GetFileName(parent) == sabHistoryItem.Title)
{
historyItem.OutputPath = parent;
}
parent = parent.GetParentPath();
}
}