From 5df50ddb3bb537b30ed1f86f7834b0ee17569585 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 1 Jul 2021 10:08:49 -0500 Subject: docs, remove Enabled --- src/slskd/Integrations/FTP/FTPService.cs | 43 +++++++++++++------------------ src/slskd/Integrations/FTP/IFTPService.cs | 7 +++-- 2 files changed, 23 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/slskd/Integrations/FTP/FTPService.cs b/src/slskd/Integrations/FTP/FTPService.cs index f9f9de66..bffc5244 100644 --- a/src/slskd/Integrations/FTP/FTPService.cs +++ b/src/slskd/Integrations/FTP/FTPService.cs @@ -25,8 +25,17 @@ namespace slskd.Integrations.FTP using Microsoft.Extensions.Logging; using static slskd.Options.IntegrationOptions; + /// + /// FTP Integration service. + /// public class FTPService : IFTPService { + /// + /// Initializes a new instance of the class. + /// + /// The FTP client factory to use. + /// The options monitor used to derive application options. + /// The logger. public FTPService( IFTPClientFactory ftpClientFactory, Microsoft.Extensions.Options.IOptionsMonitor optionsMonitor, @@ -35,37 +44,21 @@ namespace slskd.Integrations.FTP Factory = ftpClientFactory; Options = optionsMonitor.CurrentValue; Log = log; - - try - { - EncryptionMode = (FtpEncryptionMode)Enum.Parse(typeof(FtpEncryptionMode), FTPOptions.EncryptionMode, ignoreCase: true); - } - catch (Exception ex) - { - // Options should validate that the given string is parsable to FtpEncryptionMode through EnumAttribute; if this throws there's a bug somewhere. - throw new ArgumentException($"Failed to parse {typeof(FtpEncryptionMode).Name} from application Options. This is most likely a programming error; please file a GitHub issue and include your FTP configuration.", ex); - } } - public bool Enabled => !string.IsNullOrEmpty(Options.Integration.FTP.Address); - - private Options Options { get; } + private IFTPClientFactory Factory { get; set; } private FTPOptions FTPOptions => Options.Integration.FTP; private ILogger Log { get; set; } - private IFTPClientFactory Factory { get; set; } - private FtpEncryptionMode EncryptionMode { get; set; } - - public FtpClient CreateFtpClient() - { - var client = new FtpClient(FTPOptions.Address, FTPOptions.Port, FTPOptions.Username, FTPOptions.Password); - client.EncryptionMode = EncryptionMode; - - return client; - } + private Options Options { get; } + /// + /// Uploads the specified to the configured FTP server. + /// + /// The fully qualified name of the file to upload. + /// The operation context. public async Task UploadAsync(string filename) { - if (!Enabled) + if (!FTPOptions.Enabled) { Log.LogDebug("Skipping FTP upload of {filename}; FTP integration is disabled"); return; @@ -141,4 +134,4 @@ namespace slskd.Integrations.FTP return Path.Combine(Path.GetDirectoryName(filename).Replace(Path.GetDirectoryName(Path.GetDirectoryName(filename)), string.Empty), fileOnly).TrimStart('/').TrimStart('\\'); } } -} +} \ No newline at end of file diff --git a/src/slskd/Integrations/FTP/IFTPService.cs b/src/slskd/Integrations/FTP/IFTPService.cs index 5841e0b2..543138f3 100644 --- a/src/slskd/Integrations/FTP/IFTPService.cs +++ b/src/slskd/Integrations/FTP/IFTPService.cs @@ -24,8 +24,11 @@ namespace slskd.Integrations.FTP /// public interface IFTPService { - + /// + /// Uploads the specified to the configured FTP server. + /// + /// The fully qualified name of the file to upload. + /// The operation context. Task UploadAsync(string filename); - bool Enabled { get; } } } -- cgit v1.2.3