fix lint
This commit is contained in:
@@ -30,26 +30,22 @@ if ($null -eq $allFiles -or $allFiles.Count -eq 0) {
|
||||
|
||||
Write-Host "Found $($allFiles.Count) files to process." -ForegroundColor Green
|
||||
|
||||
# Calculate checksums for all files
|
||||
Write-Host "Calculating checksums (this may take a while)..." -ForegroundColor Yellow
|
||||
$filesWithChecksums = @()
|
||||
$fileCount = 0
|
||||
foreach ($file in $allFiles) {
|
||||
$fileCount++
|
||||
if ($fileCount % 50 -eq 0) {
|
||||
Write-Host " Processed $fileCount / $($allFiles.Count) files..." -ForegroundColor Gray
|
||||
}
|
||||
|
||||
# Calculate checksums for all files using parallel processing
|
||||
Write-Host "Calculating checksums using parallel processing (this may take a while)..." -ForegroundColor Yellow
|
||||
$throttleLimit = [Math]::Max(1, [Environment]::ProcessorCount)
|
||||
$parallelScriptBlock = {
|
||||
try {
|
||||
$hash = Get-FileHash -Path $file.FullName -Algorithm SHA256
|
||||
$filesWithChecksums += [PSCustomObject]@{
|
||||
File = $file
|
||||
$hash = Get-FileHash -Path $_.FullName -Algorithm SHA256
|
||||
[PSCustomObject]@{
|
||||
File = $_
|
||||
Hash = $hash.Hash
|
||||
}
|
||||
} catch {
|
||||
Write-Warning "Failed to calculate checksum for: $($file.FullName) - $($_.Exception.Message)"
|
||||
Write-Warning "Failed to calculate checksum for: $($_.FullName) - $($_.Exception.Message)"
|
||||
$null
|
||||
}
|
||||
}
|
||||
$filesWithChecksums = $allFiles | ForEach-Object -Parallel $parallelScriptBlock -ThrottleLimit $throttleLimit | Where-Object { $null -ne $_ }
|
||||
|
||||
Write-Host "Checksum calculation complete." -ForegroundColor Green
|
||||
|
||||
|
||||
Reference in New Issue
Block a user