Skip to content

Commit c02d129

Browse files
committed
Release 1.272.2025
1 parent a4327a8 commit c02d129

26 files changed

+299
-488
lines changed

Functions/GenXdev.FileSystem/EnsurePester.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Part of PowerShell module : GenXdev.FileSystem
33
Original cmdlet filename : EnsurePester.ps1
44
Original author : René Vaessen / GenXdev
5-
Version : 1.270.2025
5+
Version : 1.272.2025
66
################################################################################
77
MIT License
88

Functions/GenXdev.FileSystem/Expand-Path.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Part of PowerShell module : GenXdev.FileSystem
33
Original cmdlet filename : Expand-Path.ps1
44
Original author : René Vaessen / GenXdev
5-
Version : 1.270.2025
5+
Version : 1.272.2025
66
################################################################################
77
MIT License
88

Functions/GenXdev.FileSystem/Find-DuplicateFiles.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Part of PowerShell module : GenXdev.FileSystem
33
Original cmdlet filename : Find-DuplicateFiles.ps1
44
Original author : René Vaessen / GenXdev
5-
Version : 1.270.2025
5+
Version : 1.272.2025
66
################################################################################
77
MIT License
88

Functions/GenXdev.FileSystem/Find-Item.Cmdlet.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Part of PowerShell module : GenXdev.FileSystem
33
// Original cmdlet filename : Find-Item.Cmdlet.cs
44
// Original author : René Vaessen / GenXdev
5-
// Version : 1.270.2025
5+
// Version : 1.272.2025
66
// ################################################################################
77
// MIT License
88
//
@@ -635,14 +635,16 @@ public partial class FindItem : PSCmdlet
635635
/// </summary>
636636
[Parameter(Mandatory = false, HelpMessage = "Exclude files or directories matching these wildcard patterns (e.g., *.tmp, *\\bin\\*).")]
637637
[Alias("skiplike")]
638-
public string[] Exclude { get; set; } = new string[1] { "\\.git\\*" };
638+
public string[] Exclude { get; set; } = new string[1] { "*\\.git\\*" };
639639

640640
// Cmdlet lifecycle methods
641641
protected override void BeginProcessing()
642642
{
643643

644644
// set default parallelism if not provided by user
645-
MaxDegreeOfParallelism = MaxDegreeOfParallelism <= 0 ? GetCoreCount() * 2 : MaxDegreeOfParallelism;
645+
MaxDegreeOfParallelism = MaxDegreeOfParallelism <= 0 ? GetCoreCount() : MaxDegreeOfParallelism;
646+
ThreadPool.GetMaxThreads(out this.oldMaxWorkerThread, out this.oldMaxCompletionPorts);
647+
ThreadPool.SetMaxThreads(MaxDegreeOfParallelism, MaxDegreeOfParallelism);
646648

647649
// detect if running in unattended mode for output formatting
648650
UnattendedMode = NoLinks.IsPresent || UnattendedModeHelper.IsUnattendedMode(MyInvocation);
@@ -742,6 +744,9 @@ protected override void EndProcessing()
742744
// output completion progress
743745
WriteProgress(completeRecord);
744746

747+
// restore configuration
748+
ThreadPool.SetMaxThreads(this.oldMaxWorkerThread, this.oldMaxCompletionPorts);
749+
745750
// clean up cancellation source
746751
cts?.Dispose();
747752
}

Functions/GenXdev.FileSystem/Find-Item.Fields.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Part of PowerShell module : GenXdev.FileSystem
33
// Original cmdlet filename : Find-Item.Fields.cs
44
// Original author : René Vaessen / GenXdev
5-
// Version : 1.270.2025
5+
// Version : 1.272.2025
66
// ################################################################################
77
// MIT License
88
//
@@ -191,25 +191,27 @@ public partial class FindItem : PSCmdlet
191191
*/
192192
protected readonly ConcurrentQueue<string> DirQueue = new();
193193
protected readonly ConcurrentQueue<object> OutputQueue = new();
194-
protected readonly ConcurrentQueue<string> ProgressQueue = new();
195194
protected readonly ConcurrentQueue<string> VerboseQueue = new();
195+
protected readonly ConcurrentQueue<string> FileContentMatchQueue = new();
196196
protected readonly List<Task> Workers = new List<Task>();
197197
protected readonly object WorkersLock = new object();
198198

199199
// Cancellation source to handle timeouts and user interruptions gracefully
200-
protected CancellationTokenSource? cts;
200+
protected CancellationTokenSource cts;
201201

202202
// Counters for tracking progress: number of files found and directories
203203
// queued
204-
protected long filesFound = 0;
205-
protected long dirsQueued = 0;
206-
protected long dirsUnQueued = 0;
207-
208-
/// <summary>
209-
/// Maximum file size to process for content search, calculated based on
210-
/// available RAM
211-
/// </summary>
212-
protected long MaxFilesizeToProcess = 1024 * 1024 * 50;
204+
protected long directoryProcessors;
205+
protected long matchProcessors;
206+
protected long filesFound;
207+
protected long fileMatchesActive;
208+
protected long fileMatchesStarted;
209+
protected long fileMatchesCompleted;
210+
protected long dirsQueued;
211+
protected long dirsUnQueued;
212+
protected long lastProgress;
213+
protected int oldMaxWorkerThread;
214+
protected int oldMaxCompletionPorts;
213215

214216
/// <summary>
215217
/// Flag for enabling verbose output based on user preferences

Functions/GenXdev.FileSystem/Find-Item.Initialization.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Part of PowerShell module : GenXdev.FileSystem
33
// Original cmdlet filename : Find-Item.Initialization.cs
44
// Original author : René Vaessen / GenXdev
5-
// Version : 1.270.2025
5+
// Version : 1.272.2025
66
// ################################################################################
77
// MIT License
88
//
@@ -108,10 +108,10 @@ protected void InitializeBufferingConfiguration()
108108
// calculate max file size from ram
109109
// Calculate max file size based on available RAM to prevent memory
110110
// issues
111-
MaxFilesizeToProcess = Math.Max(1024 * 1024, Math.Min(Int32.MaxValue - 1, Convert.ToInt64(Math.Round((GetFreeRamInBytes() / 10d) / Convert.ToDouble(MaxDegreeOfParallelism), 0))));
111+
var baseBufferLength = Math.Max(1024 * 1024, Math.Min(Int32.MaxValue - 1, Convert.ToInt64(Math.Round((GetFreeRamInBytes() / 10d) / Convert.ToDouble(MaxDegreeOfParallelism), 0))));
112112

113113
// set overlap size
114-
int overlapSize = (int)Math.Max(1024 * 1024 * 5, Math.Min(MaxFilesizeToProcess / 3, 1024 * 1024 * 2));
114+
int overlapSize = (int)Math.Max(1024 * 1024 * 5, Math.Min(baseBufferLength / 3, 1024 * 1024 * 2));
115115

116116
// set buffer size
117117
PatternMatcherOptions.BufferSize = overlapSize * 3;
@@ -125,7 +125,6 @@ protected void InitializeBufferingConfiguration()
125125
// log sizes if verbose
126126
if (UseVerboseOutput)
127127
{
128-
VerboseQueue.Enqueue($"MaxFilesizeToProcess: {MaxFilesizeToProcess:N0} bytes");
129128
VerboseQueue.Enqueue($"Pattern matcher buffer size: {PatternMatcherOptions.BufferSize:N0} bytes");
130129
VerboseQueue.Enqueue($"Pattern matcher overlap size: {PatternMatcherOptions.OverlapSize:N0} bytes");
131130
}
@@ -531,9 +530,6 @@ protected void ProcessDriveSearch(DriveInfo drive, string normPath, bool isRelat
531530
catch
532531
{
533532

534-
// queue progress skip
535-
ProgressQueue.Enqueue($"Skipping drive {drive.Name} due to access issues.");
536-
537533
// queue verbose skip
538534
VerboseQueue.Enqueue($"Skipping drive {drive.Name} due to access issues.");
539535
}

0 commit comments

Comments
 (0)