Code cleanup.
This commit is contained in:
parent
5a8ab0789a
commit
7122dff9e6
1 changed files with 12 additions and 13 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Diagnostics;
|
using Serilog;
|
||||||
using Serilog;
|
|
||||||
|
|
||||||
namespace RdtClient.Service.Services.Downloaders;
|
namespace RdtClient.Service.Services.Downloaders;
|
||||||
|
|
||||||
|
|
@ -23,7 +22,7 @@ public class SymlinkDownloader : IDownloader
|
||||||
_filePath = filePath;
|
_filePath = filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<string?> Download()
|
public Task<String?> Download()
|
||||||
{
|
{
|
||||||
_logger.Debug($"Starting download of {_uri}, writing to path: {_filePath}");
|
_logger.Debug($"Starting download of {_uri}, writing to path: {_filePath}");
|
||||||
|
|
||||||
|
|
@ -36,7 +35,6 @@ public class SymlinkDownloader : IDownloader
|
||||||
Speed = 0
|
Speed = 0
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
_logger.Debug($"Searching {Settings.Get.DownloadClient.RcloneMountPath} for {fileName}");
|
_logger.Debug($"Searching {Settings.Get.DownloadClient.RcloneMountPath} for {fileName}");
|
||||||
|
|
||||||
// Recursively search for the fileName in the rclone mount location.
|
// Recursively search for the fileName in the rclone mount location.
|
||||||
|
|
@ -58,12 +56,12 @@ public class SymlinkDownloader : IDownloader
|
||||||
{
|
{
|
||||||
DownloadComplete?.Invoke(this, new DownloadCompleteEventArgs());
|
DownloadComplete?.Invoke(this, new DownloadCompleteEventArgs());
|
||||||
|
|
||||||
return Task.FromResult<string?>(actualFilePath);
|
return Task.FromResult<String?>(actualFilePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return null and try again next cycle.
|
// Return null and try again next cycle.
|
||||||
return Task.FromResult<string?>(null);
|
return Task.FromResult<String?>(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task Cancel()
|
public Task Cancel()
|
||||||
|
|
@ -85,21 +83,22 @@ public class SymlinkDownloader : IDownloader
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TryCreateSymbolicLink(string sourcePath, string symlinkPath)
|
private Boolean TryCreateSymbolicLink(String sourcePath, String symlinkPath)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
_logger.Information($"Creating symbolic link from {sourcePath} to {symlinkPath}");
|
||||||
|
|
||||||
File.CreateSymbolicLink(symlinkPath, sourcePath);
|
File.CreateSymbolicLink(symlinkPath, sourcePath);
|
||||||
if (File.Exists(symlinkPath)) // Double-check that the link was created
|
|
||||||
|
if (File.Exists(symlinkPath))
|
||||||
{
|
{
|
||||||
_logger.Information($"Created symbolic link from {sourcePath} to {symlinkPath}");
|
_logger.Information($"Created symbolic link from {sourcePath} to {symlinkPath}");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
_logger.Error($"Failed to create symbolic link from {sourcePath} to {symlinkPath}");
|
||||||
_logger.Error($"Failed to create symbolic link from {sourcePath} to {symlinkPath}");
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue