Skip to content

Extract shared download routine from parallel/sequential branches in Install-GoogleFont #214

@MariusStorhaug

Description

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions