MatchPath

This commit is contained in:
Mike Phares 2023-09-27 08:52:48 -07:00
parent c1a4eb4808
commit 0d6af37f89
3 changed files with 5 additions and 1 deletions

View File

@ -7,6 +7,7 @@ public record AppSettings(string BuildNumber,
string Company, string Company,
string Destination, string Destination,
string GitCommitSeven, string GitCommitSeven,
bool MatchPath,
int MillisecondsDelay, int MillisecondsDelay,
string WatchDirectory) string WatchDirectory)
{ {

View File

@ -10,6 +10,7 @@ public class AppSettings
public string? Company { get; set; } public string? Company { get; set; }
public string? Destination { get; set; } public string? Destination { get; set; }
public string? GitCommitSeven { get; set; } public string? GitCommitSeven { get; set; }
public bool? MatchPath { get; set; }
public int? MillisecondsDelay { get; set; } public int? MillisecondsDelay { get; set; }
public string? WatchDirectory { 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.Company is null) throw new NullReferenceException(nameof(Company));
if (appSettings.Destination is null) throw new NullReferenceException(nameof(Destination)); if (appSettings.Destination is null) throw new NullReferenceException(nameof(Destination));
if (appSettings.GitCommitSeven is null) throw new NullReferenceException(nameof(GitCommitSeven)); 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.MillisecondsDelay is null) throw new NullReferenceException(nameof(MillisecondsDelay));
if (appSettings.WatchDirectory is null) throw new NullReferenceException(nameof(WatchDirectory)); if (appSettings.WatchDirectory is null) throw new NullReferenceException(nameof(WatchDirectory));
result = new(appSettings.BuildNumber, result = new(appSettings.BuildNumber,
appSettings.Company, appSettings.Company,
appSettings.Destination, appSettings.Destination,
appSettings.GitCommitSeven, appSettings.GitCommitSeven,
appSettings.MatchPath.Value,
appSettings.MillisecondsDelay.Value, appSettings.MillisecondsDelay.Value,
appSettings.WatchDirectory); appSettings.WatchDirectory);
return result; return result;

View File

@ -37,7 +37,7 @@ public partial class Worker : BackgroundService
string[] directories = Directory.GetDirectories(_AppSettings.WatchDirectory, "*", SearchOption.TopDirectoryOnly); string[] directories = Directory.GetDirectories(_AppSettings.WatchDirectory, "*", SearchOption.TopDirectoryOnly);
foreach (string directory in directories) 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 try
{ {
if (!Directory.Exists(checkDirectory)) if (!Directory.Exists(checkDirectory))