mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Adhere to ExcludedSubpaths while scanning directory for change
This commit is contained in:
+35
-16
@@ -79,22 +79,7 @@ abstract class Module
|
|||||||
// Since we don't save anything directory specific in the has, we can skip this check if we already know that we are going to rebuild.
|
// Since we don't save anything directory specific in the has, we can skip this check if we already know that we are going to rebuild.
|
||||||
if (!needsRebuild)
|
if (!needsRebuild)
|
||||||
{
|
{
|
||||||
foreach (FileSystemInfo dirEntry in dirInfo.EnumerateFileSystemInfos("**",
|
needsRebuild = DirectoryNeedsRebuild(cacheInfo, dirInfo, source, needsRebuild);
|
||||||
enumerationOptions: new EnumerationOptions()
|
|
||||||
{ MatchType = MatchType.Win32, RecurseSubdirectories = source.Recursive }))
|
|
||||||
{
|
|
||||||
//string relativePath = Path.GetRelativePath(dirInfo.FullName, dirEntry.FullName);
|
|
||||||
//if (source.ExcludedDirectories.Contains(relativePath, StringComparer.OrdinalIgnoreCase))
|
|
||||||
// continue;
|
|
||||||
|
|
||||||
Console.WriteLine("Checking entry: " + dirEntry.FullName);
|
|
||||||
if (dirEntry.LastWriteTimeUtc > cacheInfo.LastSuccessfulBuild)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Needs rebuild");
|
|
||||||
needsRebuild = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We really just need any timestamp, to know that the directory existed at some point.
|
// We really just need any timestamp, to know that the directory existed at some point.
|
||||||
@@ -152,6 +137,40 @@ abstract class Module
|
|||||||
return needsRebuild;
|
return needsRebuild;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool DirectoryNeedsRebuild(ModuleInfo cacheInfo, DirectoryInfo dirInfo, WatchedSource source,
|
||||||
|
bool needsRebuild)
|
||||||
|
{
|
||||||
|
Stack<DirectoryInfo> directoriesToCheck = new ();
|
||||||
|
directoriesToCheck.Push(dirInfo);
|
||||||
|
|
||||||
|
while (directoriesToCheck.Count > 0)
|
||||||
|
{
|
||||||
|
DirectoryInfo directory = directoriesToCheck.Pop();
|
||||||
|
|
||||||
|
foreach (FileSystemInfo dirEntry in directory.EnumerateFileSystemInfos())
|
||||||
|
{
|
||||||
|
string relativePath = Path.GetRelativePath(dirInfo.FullName, dirEntry.FullName);
|
||||||
|
if (source.ExcludedSubpaths.Contains(relativePath, StringComparer.OrdinalIgnoreCase))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (dirEntry.Attributes.HasFlag(FileAttributes.Directory))
|
||||||
|
{
|
||||||
|
directoriesToCheck.Push(new DirectoryInfo(dirEntry.FullName));
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Checking entry: " + dirEntry.FullName);
|
||||||
|
if (dirEntry.LastWriteTimeUtc > cacheInfo.LastSuccessfulBuild)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Needs rebuild");
|
||||||
|
needsRebuild = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return needsRebuild;
|
||||||
|
}
|
||||||
|
|
||||||
private static string ComputeFileHash(string filePath)
|
private static string ComputeFileHash(string filePath)
|
||||||
{
|
{
|
||||||
using var stream = File.OpenRead(filePath);
|
using var stream = File.OpenRead(filePath);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class ScriptCoreModule : Module
|
|||||||
sources.Add(new WatchedSource("ScriptCore/", WatchMode.Metadata)
|
sources.Add(new WatchedSource("ScriptCore/", WatchMode.Metadata)
|
||||||
{
|
{
|
||||||
Recursive = true,
|
Recursive = true,
|
||||||
ExcludedDirectories =
|
ExcludedSubpaths =
|
||||||
[
|
[
|
||||||
"bin",
|
"bin",
|
||||||
"obj"
|
"obj"
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ internal record WatchedSource(string Path, WatchMode Mode)
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Only if Path points to a directory, a list of subdirectories to exclude from change checking.
|
/// Only if Path points to a directory, a list of subdirectories to exclude from change checking.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> ExcludedDirectories { get; init; } = new();
|
public List<string> ExcludedSubpaths { get; init; } = new();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Only if Path points to a directory, whether to check for changes in subdirectories as well.
|
/// Only if Path points to a directory, whether to check for changes in subdirectories as well.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user