Skip to content

馃 [Fix]: Font installs handle variants and interrupted downloads - #100

Open
Marius Storhaug (MariusStorhaug) wants to merge 16 commits into
mainfrom
install-nerdfont-followups
Open

馃 [Fix]: Font installs handle variants and interrupted downloads#100
Marius Storhaug (MariusStorhaug) wants to merge 16 commits into
mainfrom
install-nerdfont-followups

Conversation

@MariusStorhaug

@MariusStorhaug Marius Storhaug (MariusStorhaug) commented Aug 8, 2026

Copy link
Copy Markdown
Member

Font installation now recognizes the requested Standard, Mono, or Propo variant before skipping a family, keeps -WhatIf free of archive copies and network activity, and continues when an archive cannot be installed. Downloads stream directly to disk and scale concurrent work to the machine's available processor cores.

Fixed: Safer installation and archive handling

An installed standard or proportional family no longer prevents a missing Mono variant from being installed. -Force continues to download and install a requested family, while overlapping wildcard and exact names process a matching archive only once.

Archive downloads retry transient failures and enter the local cache only after extraction succeeds. A corrupt archive now reports its font-specific error and allows the remaining requested fonts to continue.

Changed: Platform-standard cache locations

macOS now uses ~/Library/Caches/PSModule/NerdFonts. Linux honors XDG_CACHE_HOME and otherwise continues to use ~/.cache/PSModule/NerdFonts.


Technical details
  • A single archive downloads directly; multiple archives share one HttpClient and queue in a RunspacePool capped at [System.Environment]::ProcessorCount.
  • The shared client uses SocketsHttpHandler connection pooling, core-bounded connections per server, and a 15-minute pooled-connection lifetime. Downloads retain ResponseHeadersRead, FileStream, CopyToAsync, atomic temporary files, a per-attempt cancellation deadline, and the existing transient retry policy.
  • Cache-copy and download creation remain guarded by ShouldProcess; filtering, deduplication, and installation run only after successful extraction.
  • Pester covers core-bounded pools, variant-specific installed checks, forced downloads, overlapping names, dry-run cache behavior, corrupt archives, strict Mono filtering, and direct .NET archive streaming.
  • Benchmark on Windows with PowerShell 7: the fresh three-font subset improved from 3.72s on installed 1.1.0 to 3.23s on this branch; the already-installed subset improved from 1.51s to 0.23s. -All results are partial because both runs stop on pre-existing cross-archive font-file collisions.
  • The restored performance harness explicitly ensures its subset is installed before the already-installed scenario and limits cleanup to Nerd Font families and their aliases.
  • Implementation plan progress: all tasks in Install-NerdFont: follow-ups from PR #77 review (variant-aware skip, -WhatIf semantics, download robustness, cache path)聽#78 are complete.
  • Issue convergence sweep: reviewed open installation issues; Add #Requires -PSEdition Core directive to Install-NerdFont聽#62 remains unrelated to this diff.
Changed surface Standards checked Framework docs checked Result
src/functions/** (PowerShell) Naming, Functions, Error Handling None (no framework-specific docs) Aligned
tests/** (Pester) PowerShell Testing None (no framework-specific docs) Aligned
scripts/** (PowerShell) Scripts, Error Handling None (no framework-specific docs) Aligned
README.md README-driven context None (no framework-specific docs) Aligned
.gitignore Repository hygiene None (no framework-specific docs) Aligned
Relevant issues (or links)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors Install-NerdFont to better handle Nerd Font variants (Standard/Mono/Propo), improve resiliency when downloads/extraction fail, and reduce unnecessary side effects during -WhatIf. It also introduces a reusable, streaming download implementation with core-bounded concurrency and standardizes cache locations on macOS/Linux.

Changes:

  • Update Install-NerdFont to (a) skip only when the requested variant is already installed, (b) guard cache copy + downloads behind ShouldProcess (keeping -WhatIf side-effect free), and (c) continue installation when extraction fails for a single archive.
  • Add private helpers to stream downloads to disk with retries (Invoke-/Start-/Receive-NerdFontDownload), plus core-bounded runspace pooling and a shared HttpClient.
  • Update tests/docs for new cache root behavior and add a performance measurement script (with .gitignore entry for results output).

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/NerdFonts.Tests.ps1 Expands coverage for streaming downloads, core-bounded concurrency, variant-aware install skipping, -Force, -WhatIf, dedupe, and extraction-failure continuation.
src/functions/public/Install-NerdFont.ps1 Variant-aware installed checks, ShouldProcess-guarded cache/download ops, streaming download workflow, runspace concurrency, and improved extraction error handling.
src/functions/private/Start-NerdFontDownload.ps1 Adds async/sync wrapper for invoking streaming download logic.
src/functions/private/Receive-NerdFontDownload.ps1 Adds completion/cleanup helper for async download operations.
src/functions/private/New-NerdFontHttpClient.ps1 Creates shared HttpClient with connection pooling knobs.
src/functions/private/New-NerdFontDownloadRunspacePool.ps1 Creates a bounded runspace pool that can invoke the download helper concurrently.
src/functions/private/Invoke-NerdFontDownload.ps1 Implements streaming download-to-disk with retries + atomic temp-file move.
src/functions/private/Get-NerdFontCacheRoot.ps1 Centralizes platform-standard cache root selection (macOS + XDG).
scripts/Measure-InstallPerformance.ps1 Adds a scriptable harness for measuring install scenarios and writing JSONL results.
README.md Documents updated cache locations and how to compute them at runtime.
.gitignore Ignores generated performance results file.

馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/functions/private/Start-NerdFontDownload.ps1 Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/functions/public/Install-NerdFont.ps1:220

  • When a cached archive exists and the user declines the "Copy cached archive" ShouldProcess prompt (e.g., via -Confirm), the function currently continues and skips the font entirely, never reaching the separate "Download archive" ShouldProcess prompt. This makes a "no" to cache-copy implicitly mean "no" to downloading, which is unexpected (and differs from the fallback behavior used when cache-copy throws).
                            Write-Warning "[$fontName] - Cache read failed, falling back to download: $($_.Exception.Message)"
                        }
                    } else {
                        continue
                    }

@MariusStorhaug
Marius Storhaug (MariusStorhaug) marked this pull request as ready for review August 8, 2026 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Install-NerdFont: follow-ups from PR #77 review (variant-aware skip, -WhatIf semantics, download robustness, cache path)

2 participants