DownloadHelper: use IFileSystem for testable filesystem access
This commit is contained in:
parent
95307f2933
commit
daf8a9c6da
2 changed files with 8 additions and 4 deletions
|
|
@ -1,11 +1,12 @@
|
||||||
using RdtClient.Data.Models.Data;
|
using System.IO.Abstractions;
|
||||||
|
using RdtClient.Data.Models.Data;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
|
|
||||||
namespace RdtClient.Service.Helpers;
|
namespace RdtClient.Service.Helpers;
|
||||||
|
|
||||||
public static class DownloadHelper
|
public static class DownloadHelper
|
||||||
{
|
{
|
||||||
public static String? GetDownloadPath(String downloadPath, Torrent torrent, Download download)
|
public static String? GetDownloadPath(String downloadPath, Torrent torrent, Download download, IFileSystem? fileSystem = null)
|
||||||
{
|
{
|
||||||
var fileUrl = download.Link;
|
var fileUrl = download.Link;
|
||||||
|
|
||||||
|
|
@ -41,9 +42,11 @@ public static class DownloadHelper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Directory.Exists(torrentPath))
|
fileSystem ??= new FileSystem();
|
||||||
|
|
||||||
|
if (!fileSystem.Directory.Exists(torrentPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(torrentPath);
|
fileSystem.Directory.CreateDirectory(torrentPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
var filePath = Path.Combine(torrentPath, fileName);
|
var filePath = Path.Combine(torrentPath, fileName);
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.39.0" />
|
<PackageReference Include="SharpCompress" Version="0.39.0" />
|
||||||
<PackageReference Include="Synology.Api.Client" Version="0.3.87" />
|
<PackageReference Include="Synology.Api.Client" Version="0.3.87" />
|
||||||
|
<PackageReference Include="TestableIO.System.IO.Abstractions" Version="21.3.1" />
|
||||||
<PackageReference Include="TorBox.NET" Version="1.4.0" />
|
<PackageReference Include="TorBox.NET" Version="1.4.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue