Skip to content

Commit 75feaf4

Browse files
Run duplicate-file removal for all variant selections, not just non-All
The deduplication of Windows Compatible folder copies was only running inside the variant-filter branch, leaving the default -Variant All path sending duplicate font files to Install-Font. Move the dedup pass outside the conditional so every extraction benefits from it.
1 parent 1a4120e commit 75feaf4

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

src/functions/public/Install-NerdFont.ps1

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -271,23 +271,25 @@ Please run the command again with elevated rights (Run as Administrator) or prov
271271
$removed++
272272
}
273273
}
274+
Write-Verbose "[$fontName] - Variant '$Variant': kept $($keep.Count), removed $removed"
275+
}
274276

275-
# Nerd Fonts archives sometimes contain duplicate matching files in
276-
# compatibility subfolders. Keep a single file per filename.
277-
$remaining = @(Get-ChildItem -Path $extractPath -Recurse -File -Include '*.ttf', '*.otf')
278-
$preferred = $remaining | Sort-Object -Property @(
279-
@{ Expression = { if ($_.FullName -match '(?i)[\\/]Windows Compatible[\\/]') { 1 } else { 0 } } }
280-
@{ Expression = { $_.FullName.Length } }
281-
)
282-
$seenFileNames = [System.Collections.Generic.HashSet[string]]::new([System.StringComparer]::OrdinalIgnoreCase)
283-
$duplicateRemoved = 0
284-
foreach ($file in $preferred) {
285-
if ($seenFileNames.Add($file.Name)) { continue }
286-
Remove-Item -LiteralPath $file.FullName -Force -ErrorAction SilentlyContinue
287-
$duplicateRemoved++
288-
}
289-
290-
Write-Verbose "[$fontName] - Variant '$Variant': kept $($keep.Count), removed $removed, deduplicated $duplicateRemoved"
277+
# Nerd Fonts archives sometimes contain duplicate matching files in
278+
# compatibility subfolders. Keep a single file per filename.
279+
$remaining = @(Get-ChildItem -Path $extractPath -Recurse -File -Include '*.ttf', '*.otf')
280+
$preferred = $remaining | Sort-Object -Property @(
281+
@{ Expression = { if ($_.FullName -match '(?i)[\\/]Windows Compatible[\\/]') { 1 } else { 0 } } }
282+
@{ Expression = { $_.FullName.Length } }
283+
)
284+
$seenFileNames = [System.Collections.Generic.HashSet[string]]::new([System.StringComparer]::OrdinalIgnoreCase)
285+
$duplicateRemoved = 0
286+
foreach ($file in $preferred) {
287+
if ($seenFileNames.Add($file.Name)) { continue }
288+
Remove-Item -LiteralPath $file.FullName -Force -ErrorAction SilentlyContinue
289+
$duplicateRemoved++
290+
}
291+
if ($duplicateRemoved -gt 0) {
292+
Write-Verbose "[$fontName] - Deduplicated $duplicateRemoved file(s)"
291293
}
292294

293295
Write-Verbose "[$fontName] - Install to [$Scope]"

0 commit comments

Comments
 (0)