Install-GoogleFont: follow-ups from PR #210 review
These are valid concerns raised by reviewers on #210 that were out of scope for the perf iteration cycle. The perf work in #210 delivered measured wins (Single −67 % / −87 %, Subset −83 % / −90 %, AlreadyInstalled −97 %); this issue captures the correctness/robustness polish layered on top.
Tasks
Origin
Raised across review comments on #210; deferred from that PR because the iteration cycle and prerelease measurements were already complete and these items belong to a separate review-able change.
Install-GoogleFont: follow-ups from PR #210 review
These are valid concerns raised by reviewers on #210 that were out of scope for the perf iteration cycle. The perf work in #210 delivered measured wins (Single −67 % / −87 %, Subset −83 % / −90 %, AlreadyInstalled −97 %); this issue captures the correctness/robustness polish layered on top.
Tasks
-Forcebypasses cache.FromCacheis computed fromTest-Pathonly and cache hits are always copied. When-Forceis set, treat the cache as cold so a fresh download is performed.-WhatIfsemantics. Downloads and cache writes happen unconditionally; with-WhatIfthe function still opens HTTP connections and writes to disk. Gate the download/copy/cache-write work behindShouldProcess(e.g. build an approved list up front).Invoke-WebRequest -RetryIntervalSec 5 -MaximumRetryCount 5to rawHttpClient.GetByteArrayAsyncremoved the existing transient-failure retries. Add a bounded retry loop around each request.$HOME/.cache/PSModule/GoogleFontsinstead of$HOME/Library/Caches/PSModule/GoogleFonts, and Linux ignores$Env:XDG_CACHE_HOME. Branch on$IsMacOSand$Env:XDG_CACHE_HOMEwhen constructing the cache root.$ProgressPreferenceoverride. It is currently set for the entire function inbeginand restored inclean. Narrow it to atry/finallyaround the download call so unrelated progress output is not suppressed, and so aclean-block exception cannot prevent restoration.cleanblock robustness. Remove the temp directory with-Recurse, and restore$ProgressPreferencebefore/independently ofRemove-Itemso a delete failure cannot leak the preference change into the caller's session.Write-Verbose "[$fontName] already installed - skipping"per entry that the skip-installed filter drops, so users understand why fewer items were processed.-Forcedoes not callInvoke-WebRequest/GetByteArrayAsync(mock-based).ABee*) installs at least one expected font.-Nameinputs.Get-Module GoogleFonts ... .ToString()throws if the module is not loaded. Capture the module object first and tolerate$null.-ResultsPathexists beforeAdd-Content, so custom output locations work.Origin
Raised across review comments on #210; deferred from that PR because the iteration cycle and prerelease measurements were already complete and these items belong to a separate review-able change.