From e6e259ed47c744db42ac8571cd949a34de19317e Mon Sep 17 00:00:00 2001 From: nihil Date: Sat, 10 May 2025 14:04:08 +0200 Subject: [PATCH] remove tasks fixed ignoring hidden folders --- RedundancyFinder/Finder.cs | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/RedundancyFinder/Finder.cs b/RedundancyFinder/Finder.cs index 0af1411..f8e3ed0 100644 --- a/RedundancyFinder/Finder.cs +++ b/RedundancyFinder/Finder.cs @@ -4,8 +4,6 @@ namespace RedundancyFinder { public class Finder { - List tasks = new List(); - Dictionary redundancies = new Dictionary(); public Dictionary Redundancies { get => redundancies; } @@ -31,21 +29,13 @@ namespace RedundancyFinder ProcessFile(path); } } - - // Wait for all tasks to complete - Task.WaitAll(tasks.ToArray()); } private void ProcessDirectory(string directoryPath) { try { - // Check if the directory is hidden and skip it if true - var attributes = File.GetAttributes(directoryPath); - if ((attributes & FileAttributes.Hidden) == FileAttributes.Hidden) - { - return; - } + // Process files in the current directory foreach (var file in Directory.GetFiles(directoryPath)) @@ -56,6 +46,13 @@ namespace RedundancyFinder // Recursively process subdirectories foreach (var subDirectory in Directory.GetDirectories(directoryPath)) { + // Check if the directory is hidden and skip it if true + var attributes = File.GetAttributes(subDirectory); + if ((attributes & FileAttributes.Hidden) == FileAttributes.Hidden) + { + continue; + } + try { ProcessDirectory(subDirectory); @@ -80,9 +77,10 @@ namespace RedundancyFinder return; } - Task task = new(() => - { - ProcessingFile?.Invoke(this, new ProcessingFileEventArgs() { Path = filePath }); + + + TaskStarted?.Invoke(this, filePath); + ProcessingFile?.Invoke(this, new ProcessingFileEventArgs() { Path = filePath }); try { @@ -113,11 +111,8 @@ namespace RedundancyFinder { FileError?.Invoke(this, new FileErrorEventArgs() { Exception = ex, Path = filePath }); } - }); - task.Start(); - TaskStarted?.Invoke(this, filePath); - tasks.Add(task); - } + + } private static string ComputeFileHash(string filePath) {