diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-12-25 17:38:22 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2022-12-25 17:38:22 -0600 |
| commit | eae965906ca09a17829eab27c6e77a11a369e446 (patch) | |
| tree | 1e78cade9112ef3ad3e0e8783b2c5dde21d50d46 /src | |
| parent | 4555f852579d3713adf3fe5e5e9234b41fd51375 (diff) | |
| download | slskd-eae965906ca09a17829eab27c6e77a11a369e446.tar.gz | |
upgrade FluentFTP to > v40
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Integrations/FTP/FTPClientFactory.cs | 13 | ||||
| -rw-r--r-- | src/slskd/Integrations/FTP/FTPService.cs | 6 | ||||
| -rw-r--r-- | src/slskd/Integrations/FTP/IFTPClientFactory.cs | 4 | ||||
| -rw-r--r-- | src/slskd/slskd.csproj | 2 |
4 files changed, 14 insertions, 11 deletions
diff --git a/src/slskd/Integrations/FTP/FTPClientFactory.cs b/src/slskd/Integrations/FTP/FTPClientFactory.cs index 70cfbc03..9e5dfc2e 100644 --- a/src/slskd/Integrations/FTP/FTPClientFactory.cs +++ b/src/slskd/Integrations/FTP/FTPClientFactory.cs @@ -19,7 +19,6 @@ using Microsoft.Extensions.Options; namespace slskd.Integrations.FTP { - using System; using FluentFTP; using static slskd.Options.IntegrationOptions; @@ -44,11 +43,15 @@ namespace slskd.Integrations.FTP /// Creates an instance of <see cref="FtpClient"/>. /// </summary> /// <returns>The created instance.</returns> - public FtpClient CreateFtpClient() + public AsyncFtpClient CreateFtpClient() { - var client = new FtpClient(FtpOptions.Address, FtpOptions.Port, FtpOptions.Username, FtpOptions.Password); - client.EncryptionMode = FtpOptions.EncryptionMode.ToEnum<FtpEncryptionMode>(); - client.ValidateAnyCertificate = FtpOptions.IgnoreCertificateErrors; + var config = new FtpConfig + { + EncryptionMode = FtpOptions.EncryptionMode.ToEnum<FtpEncryptionMode>(), + ValidateAnyCertificate = FtpOptions.IgnoreCertificateErrors, + }; + + var client = new AsyncFtpClient(FtpOptions.Address, FtpOptions.Username, FtpOptions.Password, FtpOptions.Port, config); return client; } diff --git a/src/slskd/Integrations/FTP/FTPService.cs b/src/slskd/Integrations/FTP/FTPService.cs index 11fa9709..f026d3b9 100644 --- a/src/slskd/Integrations/FTP/FTPService.cs +++ b/src/slskd/Integrations/FTP/FTPService.cs @@ -104,9 +104,9 @@ namespace slskd.Integrations.FTP using var timeoutCancellationTokenRegistration = timeoutCancellationTokenSource.Token.Register(() => timeoutTaskCompletionSource.TrySetResult(true)); - Log.LogDebug("Connecting to FTP at {Address}:{Port} using encryption mode {EncryptionMode}", client.Host, client.Port, client.EncryptionMode); + Log.LogDebug("Connecting to FTP at {Address}:{Port} using encryption mode {EncryptionMode}", client.Host, client.Port, client.Config.EncryptionMode); - var connectTask = client.ConnectAsync(); + var connectTask = client.Connect(); var completedTask = await Task.WhenAny(connectTask, timeoutTaskCompletionSource.Task); if (completedTask == timeoutTaskCompletionSource.Task) @@ -120,7 +120,7 @@ namespace slskd.Integrations.FTP } 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); + var status = await client.UploadFile(filename, remoteFilename, existsMode, createRemoteDir: true); if (status == FtpStatus.Failed) { diff --git a/src/slskd/Integrations/FTP/IFTPClientFactory.cs b/src/slskd/Integrations/FTP/IFTPClientFactory.cs index 2ab729d1..8350bbf7 100644 --- a/src/slskd/Integrations/FTP/IFTPClientFactory.cs +++ b/src/slskd/Integrations/FTP/IFTPClientFactory.cs @@ -25,9 +25,9 @@ namespace slskd.Integrations.FTP public interface IFTPClientFactory { /// <summary> - /// Creates an instance of <see cref="FtpClient"/>. + /// Creates an instance of <see cref="AsyncFtpClient"/>. /// </summary> /// <returns>The created instance.</returns> - public FtpClient CreateFtpClient(); + public AsyncFtpClient CreateFtpClient(); } } diff --git a/src/slskd/slskd.csproj b/src/slskd/slskd.csproj index 1d60fcf4..863aee96 100644 --- a/src/slskd/slskd.csproj +++ b/src/slskd/slskd.csproj @@ -42,7 +42,7 @@ </Target> <ItemGroup> - <PackageReference Include="FluentFTP" Version="39.0.1" /> + <PackageReference Include="FluentFTP" Version="43.0.1" /> <PackageReference Include="IPAddressRange" Version="4.2.0" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.0" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.0.0" /> |
