aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Integrations
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-11-08 18:56:26 -0600
committerJP Dillingham <jpdillingham@gmail.com>2021-11-08 18:56:26 -0600
commit7d936c12da1587961c22caf5dded805bcbba53de (patch)
tree1b49aa2e41a2d00164f373585798f4d9f486bf3d /src/slskd/Integrations
parentd0ef56835155e0c93393eee660297cddfb3f9cca (diff)
downloadslskd-7d936c12da1587961c22caf5dded805bcbba53de.tar.gz
tweak options for yaml compatibility
Diffstat (limited to 'src/slskd/Integrations')
-rw-r--r--src/slskd/Integrations/FTP/FTPClientFactory.cs8
-rw-r--r--src/slskd/Integrations/FTP/FTPService.cs20
2 files changed, 14 insertions, 14 deletions
diff --git a/src/slskd/Integrations/FTP/FTPClientFactory.cs b/src/slskd/Integrations/FTP/FTPClientFactory.cs
index e9ee0721..2e41ab03 100644
--- a/src/slskd/Integrations/FTP/FTPClientFactory.cs
+++ b/src/slskd/Integrations/FTP/FTPClientFactory.cs
@@ -37,7 +37,7 @@ namespace slskd.Integrations.FTP
OptionsMonitor = optionsMonitor;
}
- private FTPOptions FTPOptions => OptionsMonitor.CurrentValue.Integration.FTP;
+ private FtpOptions FtpOptions => OptionsMonitor.CurrentValue.Integration.Ftp;
private IOptionsMonitor<Options> OptionsMonitor { get; set; }
/// <summary>
@@ -46,9 +46,9 @@ namespace slskd.Integrations.FTP
/// <returns>The created instance.</returns>
public FtpClient CreateFtpClient()
{
- var client = new FtpClient(FTPOptions.Address, FTPOptions.Port, FTPOptions.Username, FTPOptions.Password);
- client.EncryptionMode = ParseFtpEncryptionMode(FTPOptions.EncryptionMode);
- client.ValidateAnyCertificate = FTPOptions.IgnoreCertificateErrors;
+ var client = new FtpClient(FtpOptions.Address, FtpOptions.Port, FtpOptions.Username, FtpOptions.Password);
+ client.EncryptionMode = ParseFtpEncryptionMode(FtpOptions.EncryptionMode);
+ client.ValidateAnyCertificate = FtpOptions.IgnoreCertificateErrors;
return client;
}
diff --git a/src/slskd/Integrations/FTP/FTPService.cs b/src/slskd/Integrations/FTP/FTPService.cs
index becf1a12..dd1b340f 100644
--- a/src/slskd/Integrations/FTP/FTPService.cs
+++ b/src/slskd/Integrations/FTP/FTPService.cs
@@ -49,7 +49,7 @@ namespace slskd.Integrations.FTP
}
private IFTPClientFactory Factory { get; set; }
- private FTPOptions FTPOptions => OptionsMonitor.CurrentValue.Integration.FTP;
+ private FtpOptions FtpOptions => OptionsMonitor.CurrentValue.Integration.Ftp;
private ILogger<FTPService> Log { get; set; }
private IOptionsMonitor<Options> OptionsMonitor { get; }
@@ -60,7 +60,7 @@ namespace slskd.Integrations.FTP
/// <returns>The operation context.</returns>
public async Task UploadAsync(string filename)
{
- if (!FTPOptions.Enabled)
+ if (!FtpOptions.Enabled)
{
Log.LogDebug("Skipping FTP upload of {filename}; FTP integration is disabled");
return;
@@ -74,7 +74,7 @@ namespace slskd.Integrations.FTP
task: () => AttemptUploadAsync(filename),
isRetryable: (attempts, ex) => true,
onFailure: (attempts, ex) => Log.LogInformation("Failed attempt {Attempts} to upload {Filename} to FTP: {Message}", attempts, fileAndParentDirectory, ex.Message),
- maxAttempts: FTPOptions.RetryAttempts,
+ maxAttempts: FtpOptions.RetryAttempts,
maxDelayInMilliseconds: 30000);
}
catch (RetryException ex)
@@ -84,7 +84,7 @@ namespace slskd.Integrations.FTP
}
catch (Exception ex)
{
- Log.LogWarning("Failed to upload {Filename} to FTP after {Attempts} attempts: {Message}", fileAndParentDirectory, FTPOptions.RetryAttempts, ex.Message);
+ Log.LogWarning("Failed to upload {Filename} to FTP after {Attempts} attempts: {Message}", fileAndParentDirectory, FtpOptions.RetryAttempts, ex.Message);
throw;
}
}
@@ -92,15 +92,15 @@ namespace slskd.Integrations.FTP
private async Task AttemptUploadAsync(string filename)
{
var fileAndParentDirectory = GetFileAndParentDirectoryFromFilename(filename);
- var remotePath = FTPOptions.RemotePath.TrimEnd('/').TrimEnd('\\');
+ var remotePath = FtpOptions.RemotePath.TrimEnd('/').TrimEnd('\\');
var remoteFilename = $"{remotePath}/{fileAndParentDirectory}";
- var existsMode = FTPOptions.OverwriteExisting ? FtpRemoteExists.Overwrite : FtpRemoteExists.Skip;
+ var existsMode = FtpOptions.OverwriteExisting ? FtpRemoteExists.Overwrite : FtpRemoteExists.Skip;
using var client = Factory.CreateFtpClient();
var timeoutTaskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
- using var timeoutCancellationTokenSource = new CancellationTokenSource(TimeSpan.FromMilliseconds(FTPOptions.ConnectionTimeout));
+ using var timeoutCancellationTokenSource = new CancellationTokenSource(TimeSpan.FromMilliseconds(FtpOptions.ConnectionTimeout));
using var timeoutCancellationTokenRegistration =
timeoutCancellationTokenSource.Token.Register(() => timeoutTaskCompletionSource.TrySetResult(true));
@@ -111,7 +111,7 @@ namespace slskd.Integrations.FTP
if (completedTask == timeoutTaskCompletionSource.Task)
{
- throw new TimeoutException($"Failed to connect to server after {FTPOptions.ConnectionTimeout}ms");
+ throw new TimeoutException($"Failed to connect to server after {FtpOptions.ConnectionTimeout}ms");
}
if (connectTask.Exception != null)
@@ -119,7 +119,7 @@ namespace slskd.Integrations.FTP
throw connectTask.Exception;
}
- Log.LogInformation("Uploading {Filename} to FTP {Address}:{Port} as {RemoteFilename}", fileAndParentDirectory, FTPOptions.Address, FTPOptions.Port, remoteFilename);
+ Log.LogInformation("Uploading {Filename} to FTP {Address}:{Port} as {RemoteFilename}", fileAndParentDirectory, FtpOptions.Address, FtpOptions.Port, remoteFilename);
var status = await client.UploadFileAsync(filename, remoteFilename, existsMode, createRemoteDir: true);
if (status == FtpStatus.Failed)
@@ -127,7 +127,7 @@ namespace slskd.Integrations.FTP
throw new FtpException("FTP client reported a failed transfer");
}
- Log.LogInformation("FTP upload of {Filename} to {Address}:{Port} complete", fileAndParentDirectory, FTPOptions.Address, FTPOptions.Port);
+ Log.LogInformation("FTP upload of {Filename} to {Address}:{Port} complete", fileAndParentDirectory, FtpOptions.Address, FtpOptions.Port);
}
private string GetFileAndParentDirectoryFromFilename(string filename)