mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-17 15:02:34 +02:00
Fixed: Map dsm shared folder to full path in status (#797)
* Fixed: Map dsm shared folder to full path in status * Add tests * fix tests
This commit is contained in:
parent
f29e7557dd
commit
0a589c529f
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
@ -7,6 +7,7 @@
|
|||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Common.Http;
|
using NzbDrone.Common.Http;
|
||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
|
using NzbDrone.Core.Download.Clients;
|
||||||
using NzbDrone.Core.Download.Clients.DownloadStation;
|
using NzbDrone.Core.Download.Clients.DownloadStation;
|
||||||
using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
|
using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
|
||||||
using NzbDrone.Core.MediaFiles.TorrentInfo;
|
using NzbDrone.Core.MediaFiles.TorrentInfo;
|
||||||
@ -296,6 +297,17 @@ protected void GivenSharedFolder()
|
|||||||
.Returns<OsPath, DownloadStationSettings, string>((path, setttings, serial) => _physicalPath);
|
.Returns<OsPath, DownloadStationSettings, string>((path, setttings, serial) => _physicalPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void GivenSharedFolder(string share)
|
||||||
|
{
|
||||||
|
Mocker.GetMock<ISharedFolderResolver>()
|
||||||
|
.Setup(s => s.RemapToFullPath(It.IsAny<OsPath>(), It.IsAny<DownloadStationSettings>(), It.IsAny<string>()))
|
||||||
|
.Throws(new DownloadClientException("There is no matching shared folder"));
|
||||||
|
|
||||||
|
Mocker.GetMock<ISharedFolderResolver>()
|
||||||
|
.Setup(s => s.RemapToFullPath(It.Is<OsPath>(x => x.FullPath == share), It.IsAny<DownloadStationSettings>(), It.IsAny<string>()))
|
||||||
|
.Returns<OsPath, DownloadStationSettings, string>((path, setttings, serial) => _physicalPath);
|
||||||
|
}
|
||||||
|
|
||||||
protected void GivenSerialNumber()
|
protected void GivenSerialNumber()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<ISerialNumberProvider>()
|
Mocker.GetMock<ISerialNumberProvider>()
|
||||||
@ -495,6 +507,41 @@ public void Download_should_throw_and_not_add_task_if_cannot_get_serial_number()
|
|||||||
.Verify(v => v.AddTaskFromUrl(It.IsAny<string>(), null, _settings), Times.Never());
|
.Verify(v => v.AddTaskFromUrl(It.IsAny<string>(), null, _settings), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetStatus_should_map_outputpath_when_using_default()
|
||||||
|
{
|
||||||
|
GivenSerialNumber();
|
||||||
|
GivenSharedFolder("/somepath");
|
||||||
|
|
||||||
|
var status = Subject.GetStatus();
|
||||||
|
|
||||||
|
status.OutputRootFolders.First().Should().Be(_physicalPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetStatus_should_map_outputpath_when_using_destination()
|
||||||
|
{
|
||||||
|
GivenSerialNumber();
|
||||||
|
GivenTvDirectory();
|
||||||
|
GivenSharedFolder($"/{_tvDirectory}");
|
||||||
|
|
||||||
|
var status = Subject.GetStatus();
|
||||||
|
|
||||||
|
status.OutputRootFolders.First().Should().Be(_physicalPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetStatus_should_map_outputpath_when_using_category()
|
||||||
|
{
|
||||||
|
GivenSerialNumber();
|
||||||
|
GivenTvCategory();
|
||||||
|
GivenSharedFolder($"/somepath/{_category}");
|
||||||
|
|
||||||
|
var status = Subject.GetStatus();
|
||||||
|
|
||||||
|
status.OutputRootFolders.First().Should().Be(_physicalPath);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void GetItems_should_set_outputPath_to_base_folder_when_single_file_non_finished_tasks()
|
public void GetItems_should_set_outputPath_to_base_folder_when_single_file_non_finished_tasks()
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Common.Http;
|
using NzbDrone.Common.Http;
|
||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
|
using NzbDrone.Core.Download.Clients;
|
||||||
using NzbDrone.Core.Download.Clients.DownloadStation;
|
using NzbDrone.Core.Download.Clients.DownloadStation;
|
||||||
using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
|
using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
|
||||||
using NzbDrone.Core.Organizer;
|
using NzbDrone.Core.Organizer;
|
||||||
@ -188,6 +189,17 @@ protected void GivenSharedFolder()
|
|||||||
.Returns<OsPath, DownloadStationSettings, string>((path, setttings, serial) => _physicalPath);
|
.Returns<OsPath, DownloadStationSettings, string>((path, setttings, serial) => _physicalPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void GivenSharedFolder(string share)
|
||||||
|
{
|
||||||
|
Mocker.GetMock<ISharedFolderResolver>()
|
||||||
|
.Setup(s => s.RemapToFullPath(It.IsAny<OsPath>(), It.IsAny<DownloadStationSettings>(), It.IsAny<string>()))
|
||||||
|
.Throws(new DownloadClientException("There is no matching shared folder"));
|
||||||
|
|
||||||
|
Mocker.GetMock<ISharedFolderResolver>()
|
||||||
|
.Setup(s => s.RemapToFullPath(It.Is<OsPath>(x => x.FullPath == share), It.IsAny<DownloadStationSettings>(), It.IsAny<string>()))
|
||||||
|
.Returns<OsPath, DownloadStationSettings, string>((path, setttings, serial) => _physicalPath);
|
||||||
|
}
|
||||||
|
|
||||||
protected void GivenSerialNumber()
|
protected void GivenSerialNumber()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<ISerialNumberProvider>()
|
Mocker.GetMock<ISerialNumberProvider>()
|
||||||
@ -377,6 +389,41 @@ public void Download_should_throw_and_not_add_task_if_cannot_get_serial_number()
|
|||||||
.Verify(v => v.AddTaskFromUrl(It.IsAny<string>(), null, _settings), Times.Never());
|
.Verify(v => v.AddTaskFromUrl(It.IsAny<string>(), null, _settings), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetStatus_should_map_outputpath_when_using_default()
|
||||||
|
{
|
||||||
|
GivenSerialNumber();
|
||||||
|
GivenSharedFolder("/somepath");
|
||||||
|
|
||||||
|
var status = Subject.GetStatus();
|
||||||
|
|
||||||
|
status.OutputRootFolders.First().Should().Be(_physicalPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetStatus_should_map_outputpath_when_using_destination()
|
||||||
|
{
|
||||||
|
GivenSerialNumber();
|
||||||
|
GivenTvDirectory();
|
||||||
|
GivenSharedFolder($"/{_tvDirectory}");
|
||||||
|
|
||||||
|
var status = Subject.GetStatus();
|
||||||
|
|
||||||
|
status.OutputRootFolders.First().Should().Be(_physicalPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetStatus_should_map_outputpath_when_using_category()
|
||||||
|
{
|
||||||
|
GivenSerialNumber();
|
||||||
|
GivenTvCategory();
|
||||||
|
GivenSharedFolder($"/somepath/{_category}");
|
||||||
|
|
||||||
|
var status = Subject.GetStatus();
|
||||||
|
|
||||||
|
status.OutputRootFolders.First().Should().Be(_physicalPath);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void GetItems_should_not_map_outputpath_for_queued_or_downloading_tasks()
|
public void GetItems_should_not_map_outputpath_for_queued_or_downloading_tasks()
|
||||||
{
|
{
|
||||||
|
@ -115,12 +115,15 @@ public override DownloadClientInfo GetStatus()
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var path = GetDownloadDirectory();
|
var serialNumber = _serialNumberProvider.GetSerialNumber(Settings);
|
||||||
|
var sharedFolder = GetDownloadDirectory() ?? GetDefaultDir();
|
||||||
|
var outputPath = new OsPath($"/{sharedFolder.TrimStart('/')}");
|
||||||
|
var path = _sharedFolderResolver.RemapToFullPath(outputPath, Settings, serialNumber);
|
||||||
|
|
||||||
return new DownloadClientInfo
|
return new DownloadClientInfo
|
||||||
{
|
{
|
||||||
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
|
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
|
||||||
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(path)) }
|
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, path) }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
catch (DownloadClientException e)
|
catch (DownloadClientException e)
|
||||||
|
@ -139,12 +139,15 @@ public override DownloadClientInfo GetStatus()
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var path = GetDownloadDirectory();
|
var serialNumber = _serialNumberProvider.GetSerialNumber(Settings);
|
||||||
|
var sharedFolder = GetDownloadDirectory() ?? GetDefaultDir();
|
||||||
|
var outputPath = new OsPath($"/{sharedFolder.TrimStart('/')}");
|
||||||
|
var path = _sharedFolderResolver.RemapToFullPath(outputPath, Settings, serialNumber);
|
||||||
|
|
||||||
return new DownloadClientInfo
|
return new DownloadClientInfo
|
||||||
{
|
{
|
||||||
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
|
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
|
||||||
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(path)) }
|
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, path) }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
catch (DownloadClientException e)
|
catch (DownloadClientException e)
|
||||||
|
Loading…
Reference in New Issue
Block a user