aboutsummaryrefslogtreecommitdiff
path: root/src/Publishing/MinioUploadManager.cs
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-09-06 20:50:06 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2024-09-06 20:50:06 -0400
commit7f1482c5d77b1b5f7e369ade925d2351d7623fa1 (patch)
treec99a0c8a0137e940492892977ef1e4f6f42b6d52 /src/Publishing/MinioUploadManager.cs
parent79d824cfb0e0cc9ff4fab0e0c546a83c0edaae1c (diff)
cleanup and add fluent-ftp as an publishing location
Diffstat (limited to 'src/Publishing/MinioUploadManager.cs')
-rw-r--r--src/Publishing/MinioUploadManager.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/Publishing/MinioUploadManager.cs b/src/Publishing/MinioUploadManager.cs
new file mode 100644
index 0000000..502392f
--- /dev/null
+++ b/src/Publishing/MinioUploadManager.cs
@@ -0,0 +1,43 @@
+using System.Threading.Tasks;
+using System.Diagnostics.CodeAnalysis;
+
+using VNLib.Tools.Build.Executor.Model;
+
+using static VNLib.Tools.Build.Executor.Constants.Utils;
+
+namespace VNLib.Tools.Build.Executor.Publishing
+{
+
+ internal sealed class MinioUploadManager : IUploadManager
+ {
+ private readonly string _minioPath;
+
+ private MinioUploadManager(string minioPath) => _minioPath = minioPath;
+
+ public async Task UploadDirectoryAsync(string path)
+ {
+ //Recursivley copy all files in the working directory
+ string[] args =
+ {
+ "cp",
+ "--recursive",
+ ".",
+ _minioPath
+ };
+
+ //Set working dir to the supplied dir path, and run the command
+ int result = await RunProcessAsync("mc", path, args);
+
+ if (result != 0)
+ {
+ throw new BuildFailedException($"Failed to upload directory {path} with status code {result:x}");
+ }
+ }
+
+ [return: NotNullIfNotNull(nameof(uploadPath))]
+ public static IUploadManager? Create(string? uploadPath)
+ {
+ return string.IsNullOrWhiteSpace(uploadPath) ? null : new MinioUploadManager(uploadPath);
+ }
+ }
+} \ No newline at end of file