The download+retry+cache-write logic in Install-GoogleFont is duplicated between the ForEach-Object -Parallel branch (PS 7+) and the sequential fallback branch. This creates a maintenance risk where a future fix applied to one path may not be applied to the other.
Request
Extract the per-item download routine (retry loop, progress suppression, cache write, error handling) into a shared scriptblock or helper function that both the parallel and sequential branches invoke. This ensures behavior stays consistent across both paths.
Context
Identified during PR review of PR #210 (review thread). The duplication was introduced to support both PowerShell 7+ (parallel) and PowerShell 5.1 (sequential) without a breaking change, but the shared logic should be factored out.
Technical Considerations
ForEach-Object -Parallel runs in isolated runspaces, so outer-scope scriptblocks cannot be directly invoked — the shared code must either be passed via $using: as a scriptblock, defined as a module-scoped function, or structured so both paths call into the same implementation.
- The extracted routine should handle: bounded retry with delay, progress preference scoping, cache write with error handling, and result reporting.
Related
The download+retry+cache-write logic in
Install-GoogleFontis duplicated between theForEach-Object -Parallelbranch (PS 7+) and the sequential fallback branch. This creates a maintenance risk where a future fix applied to one path may not be applied to the other.Request
Extract the per-item download routine (retry loop, progress suppression, cache write, error handling) into a shared scriptblock or helper function that both the parallel and sequential branches invoke. This ensures behavior stays consistent across both paths.
Context
Identified during PR review of PR #210 (review thread). The duplication was introduced to support both PowerShell 7+ (parallel) and PowerShell 5.1 (sequential) without a breaking change, but the shared logic should be factored out.
Technical Considerations
ForEach-Object -Parallelruns in isolated runspaces, so outer-scope scriptblocks cannot be directly invoked — the shared code must either be passed via$using:as a scriptblock, defined as a module-scoped function, or structured so both paths call into the same implementation.Related