diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-07-02 08:06:39 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-07-02 08:06:39 -0500 |
| commit | 32cd804dd3e13967a14316ae76ae2ce71c3de936 (patch) | |
| tree | 3f67ea09cfb52e4108bf2f00dc8b40744b66964e /src | |
| parent | dfd8015a0727d2074282d93d7911f988195b20f9 (diff) | |
| download | slskd-32cd804dd3e13967a14316ae76ae2ce71c3de936.tar.gz | |
dispose FTP client
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Integrations/FTP/FTPService.cs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/slskd/Integrations/FTP/FTPService.cs b/src/slskd/Integrations/FTP/FTPService.cs index bffc5244..a5fe6a8f 100644 --- a/src/slskd/Integrations/FTP/FTPService.cs +++ b/src/slskd/Integrations/FTP/FTPService.cs @@ -95,17 +95,16 @@ namespace slskd.Integrations.FTP var existsMode = FTPOptions.OverwriteExisting ? FtpRemoteExists.Overwrite : FtpRemoteExists.Skip; - Log.LogInformation("Uploading {Filename} to FTP {Address}:{Port} as {RemoteFilename}", fileAndParentDirectory, FTPOptions.Address, FTPOptions.Port, remoteFilename); - var client = Factory.CreateFtpClient(); - client.ValidateAnyCertificate = FTPOptions.IgnoreCertificateErrors; + using var client = Factory.CreateFtpClient(); var timeoutTaskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously); using var timeoutCancellationTokenSource = new CancellationTokenSource(TimeSpan.FromMilliseconds(FTPOptions.ConnectionTimeout)); using var timeoutCancellationTokenRegistration = timeoutCancellationTokenSource.Token.Register(() => timeoutTaskCompletionSource.TrySetResult(true)); - var connectTask = client.ConnectAsync(); + Log.LogDebug("Connecting to FTP at {Address}:{Port} using encryption mode {EncryptionMode}", client.Host, client.Port, client.EncryptionMode); + var connectTask = client.ConnectAsync(); var completedTask = await Task.WhenAny(connectTask, timeoutTaskCompletionSource.Task); if (completedTask == timeoutTaskCompletionSource.Task) @@ -118,6 +117,7 @@ namespace slskd.Integrations.FTP throw connectTask.Exception; } + 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) |
