remove tasks
fixed ignoring hidden folders
This commit is contained in:
parent
775e915cfa
commit
e6e259ed47
@ -4,8 +4,6 @@ namespace RedundancyFinder
|
|||||||
{
|
{
|
||||||
public class Finder
|
public class Finder
|
||||||
{
|
{
|
||||||
List<Task> tasks = new List<Task>();
|
|
||||||
|
|
||||||
Dictionary<string, Redundancy> redundancies = new Dictionary<string, Redundancy>();
|
Dictionary<string, Redundancy> redundancies = new Dictionary<string, Redundancy>();
|
||||||
|
|
||||||
public Dictionary<string, Redundancy> Redundancies { get => redundancies; }
|
public Dictionary<string, Redundancy> Redundancies { get => redundancies; }
|
||||||
@ -31,21 +29,13 @@ namespace RedundancyFinder
|
|||||||
ProcessFile(path);
|
ProcessFile(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for all tasks to complete
|
|
||||||
Task.WaitAll(tasks.ToArray());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProcessDirectory(string directoryPath)
|
private void ProcessDirectory(string directoryPath)
|
||||||
{
|
{
|
||||||
try
|
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
|
// Process files in the current directory
|
||||||
foreach (var file in Directory.GetFiles(directoryPath))
|
foreach (var file in Directory.GetFiles(directoryPath))
|
||||||
@ -56,6 +46,13 @@ namespace RedundancyFinder
|
|||||||
// Recursively process subdirectories
|
// Recursively process subdirectories
|
||||||
foreach (var subDirectory in Directory.GetDirectories(directoryPath))
|
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
|
try
|
||||||
{
|
{
|
||||||
ProcessDirectory(subDirectory);
|
ProcessDirectory(subDirectory);
|
||||||
@ -80,9 +77,10 @@ namespace RedundancyFinder
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Task task = new(() =>
|
|
||||||
{
|
|
||||||
ProcessingFile?.Invoke(this, new ProcessingFileEventArgs() { Path = filePath });
|
TaskStarted?.Invoke(this, filePath);
|
||||||
|
ProcessingFile?.Invoke(this, new ProcessingFileEventArgs() { Path = filePath });
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -113,11 +111,8 @@ namespace RedundancyFinder
|
|||||||
{
|
{
|
||||||
FileError?.Invoke(this, new FileErrorEventArgs() { Exception = ex, Path = filePath });
|
FileError?.Invoke(this, new FileErrorEventArgs() { Exception = ex, Path = filePath });
|
||||||
}
|
}
|
||||||
});
|
|
||||||
task.Start();
|
}
|
||||||
TaskStarted?.Invoke(this, filePath);
|
|
||||||
tasks.Add(task);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string ComputeFileHash(string filePath)
|
private static string ComputeFileHash(string filePath)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user