From 0d6af37f89b748613ce3136ac03f3c6c23ef1fa9 Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Wed, 27 Sep 2023 08:52:48 -0700 Subject: [PATCH] MatchPath --- Models/AppSettings.cs | 1 + Models/Binder/AppSettings.cs | 3 +++ Worker.cs | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Models/AppSettings.cs b/Models/AppSettings.cs index 552225b..b069f0a 100644 --- a/Models/AppSettings.cs +++ b/Models/AppSettings.cs @@ -7,6 +7,7 @@ public record AppSettings(string BuildNumber, string Company, string Destination, string GitCommitSeven, + bool MatchPath, int MillisecondsDelay, string WatchDirectory) { diff --git a/Models/Binder/AppSettings.cs b/Models/Binder/AppSettings.cs index 9f45651..529da4b 100644 --- a/Models/Binder/AppSettings.cs +++ b/Models/Binder/AppSettings.cs @@ -10,6 +10,7 @@ public class AppSettings public string? Company { get; set; } public string? Destination { get; set; } public string? GitCommitSeven { get; set; } + public bool? MatchPath { get; set; } public int? MillisecondsDelay { get; set; } public string? WatchDirectory { get; set; } @@ -27,12 +28,14 @@ public class AppSettings if (appSettings.Company is null) throw new NullReferenceException(nameof(Company)); if (appSettings.Destination is null) throw new NullReferenceException(nameof(Destination)); if (appSettings.GitCommitSeven is null) throw new NullReferenceException(nameof(GitCommitSeven)); + if (appSettings.MatchPath is null) throw new NullReferenceException(nameof(MatchPath)); if (appSettings.MillisecondsDelay is null) throw new NullReferenceException(nameof(MillisecondsDelay)); if (appSettings.WatchDirectory is null) throw new NullReferenceException(nameof(WatchDirectory)); result = new(appSettings.BuildNumber, appSettings.Company, appSettings.Destination, appSettings.GitCommitSeven, + appSettings.MatchPath.Value, appSettings.MillisecondsDelay.Value, appSettings.WatchDirectory); return result; diff --git a/Worker.cs b/Worker.cs index 3f3c7d6..a2c38cb 100644 --- a/Worker.cs +++ b/Worker.cs @@ -37,7 +37,7 @@ public partial class Worker : BackgroundService string[] directories = Directory.GetDirectories(_AppSettings.WatchDirectory, "*", SearchOption.TopDirectoryOnly); foreach (string directory in directories) { - checkDirectory = Path.Combine(_AppSettings.Destination, Path.GetFileName(directory)); + checkDirectory = !_AppSettings.MatchPath ? _AppSettings.Destination : Path.Combine(_AppSettings.Destination, Path.GetFileName(directory)); try { if (!Directory.Exists(checkDirectory))