aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-07-01 10:08:49 -0500
committerJP Dillingham <jpdillingham@gmail.com>2021-07-01 10:08:49 -0500
commit5df50ddb3bb537b30ed1f86f7834b0ee17569585 (patch)
tree4d489e959d027356ffb6048261ea8322856ae406
parent34a25f488eecee202cbed8d8c2ee64bd60439ab4 (diff)
downloadslskd-5df50ddb3bb537b30ed1f86f7834b0ee17569585.tar.gz
docs, remove Enabled
-rw-r--r--src/slskd/Integrations/FTP/FTPService.cs43
-rw-r--r--src/slskd/Integrations/FTP/IFTPService.cs7
2 files changed, 23 insertions, 27 deletions
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;
+ /// <summary>
+ /// FTP Integration service.
+ /// </summary>
public class FTPService : IFTPService
{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="FTPService"/> class.
+ /// </summary>
+ /// <param name="ftpClientFactory">The FTP client factory to use.</param>
+ /// <param name="optionsMonitor">The options monitor used to derive application options.</param>
+ /// <param name="log">The logger.</param>
public FTPService(
IFTPClientFactory ftpClientFactory,
Microsoft.Extensions.Options.IOptionsMonitor<Options> 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<FTPService> 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; }
+ /// <summary>
+ /// Uploads the specified <paramref name="filename"/> to the configured FTP server.
+ /// </summary>
+ /// <param name="filename">The fully qualified name of the file to upload.</param>
+ /// <returns>The operation context.</returns>
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
/// </summary>
public interface IFTPService
{
-
+ /// <summary>
+ /// Uploads the specified <paramref name="filename"/> to the configured FTP server.
+ /// </summary>
+ /// <param name="filename">The fully qualified name of the file to upload.</param>
+ /// <returns>The operation context.</returns>
Task UploadAsync(string filename);
- bool Enabled { get; }
}
}