fix exclusion checks
This commit is contained in:
parent
85a562079c
commit
57fdc83cb5
@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Linq;
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
@ -15,11 +14,21 @@ public static class FileHelper
|
|||||||
{
|
{
|
||||||
foreach (var dir in sourceDir.GetDirectories("*", SearchOption.AllDirectories))
|
foreach (var dir in sourceDir.GetDirectories("*", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
if (exclusions.Contains(dir.FullName.Replace(sourceDir.FullName, "")))
|
var exclude = false;
|
||||||
|
|
||||||
|
foreach (var exclusion in exclusions)
|
||||||
{
|
{
|
||||||
Log.Information($"Excluding Dir: {dir.FullName}");
|
var currentDirRelativePath = dir.FullName.Replace(sourceDir.FullName, "");
|
||||||
continue;
|
|
||||||
|
if (currentDirRelativePath.StartsWith(exclusion) || currentDirRelativePath == exclusion)
|
||||||
|
{
|
||||||
|
exclude = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exclude)
|
||||||
|
continue;
|
||||||
|
|
||||||
Directory.CreateDirectory(dir.FullName.Replace(sourceDir.FullName, targetDir.FullName));
|
Directory.CreateDirectory(dir.FullName.Replace(sourceDir.FullName, targetDir.FullName));
|
||||||
}
|
}
|
||||||
@ -41,6 +50,8 @@ public static class FileHelper
|
|||||||
|
|
||||||
foreach (var file in sourceDir.GetFiles("*.*", SearchOption.AllDirectories))
|
foreach (var file in sourceDir.GetFiles("*.*", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
|
var exclude = false;
|
||||||
|
|
||||||
updateCallback?.Invoke(file.Name, (int)Math.Floor(((double)processedFiles / totalFiles) * 100));
|
updateCallback?.Invoke(file.Name, (int)Math.Floor(((double)processedFiles / totalFiles) * 100));
|
||||||
|
|
||||||
foreach (var exclusion in exclusions)
|
foreach (var exclusion in exclusions)
|
||||||
@ -49,9 +60,13 @@ public static class FileHelper
|
|||||||
|
|
||||||
if (currentFileRelativePath.StartsWith(exclusion) || currentFileRelativePath == exclusion)
|
if (currentFileRelativePath.StartsWith(exclusion) || currentFileRelativePath == exclusion)
|
||||||
{
|
{
|
||||||
|
exclude = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exclude)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
File.Copy(file.FullName, file.FullName.Replace(sourceDir.FullName, targetDir.FullName), true);
|
File.Copy(file.FullName, file.FullName.Replace(sourceDir.FullName, targetDir.FullName), true);
|
||||||
processedFiles++;
|
processedFiles++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user