Skip to content

fix(CLI): cache ignored when using --parallel with phrase pull#1085

Merged
Sven Dunemann (forelabs) merged 7 commits intophrase:mainfrom
tetienne:fix/pull-cache-ignored-with-parallel
Apr 27, 2026
Merged

fix(CLI): cache ignored when using --parallel with phrase pull#1085
Sven Dunemann (forelabs) merged 7 commits intophrase:mainfrom
tetienne:fix/pull-cache-ignored-with-parallel

Conversation

@tetienne
Copy link
Copy Markdown
Contributor

@tetienne Thibaut Etienne (tetienne) commented Apr 3, 2026

When splitting the work between #1066 (--cache) and #1067 (--parallel), I forgot to thread the cache through the parallel code path. As a result, --cache --parallel silently ignored the cache: no conditional headers were sent, no ETags were stored, and every run re-downloaded all locale files.

Tested against a production project with 204 locale files:

# First run — populates cache
$ ./phrase pull --cache --parallel
Downloaded en to locales/en/tradfile.json
...
(204 files downloaded)

# Second run — all 304s, nothing re-downloaded
$ ./phrase pull --cache --parallel
Not modified locales/en/tradfile.json
...
(204 files skipped)

Test plan

  • go build compiles
  • Manual test: phrase pull --cache --parallel second run returns 304 for all files
  • phrase pull --parallel without --cache behaves identically to before
  • phrase pull --cache without --parallel unaffected

@tetienne Thibaut Etienne (tetienne) marked this pull request as draft April 3, 2026 06:29
Restore ctx.Err() check in PullParallel goroutines to respect
context cancellation after first failure. Make copyToDestination
fail explicitly on nil file instead of silently creating empty
files. Remove dead 304 check after rate-limit retry. Simplify
pull dispatch by replacing pullFn type with if/else. Add mutex
to Save() and json:"-" to mu field for defensive thread safety.
@tetienne Thibaut Etienne (tetienne) marked this pull request as ready for review April 3, 2026 08:20
Comment thread clients/cli/cmd/internal/pull.go
@tetienne
Copy link
Copy Markdown
Contributor Author

jablan Do you think you can have a look this week?

@forelabs
Copy link
Copy Markdown
Member

Sven Dunemann (forelabs) commented Apr 27, 2026

Thibaut Etienne (@tetienne) We had de change our priorities a bit. We will now pick it up again. There is a conflict, can you take care of it please? Thank you a lot for your support.

@forelabs Sven Dunemann (forelabs) added the enhancement New feature or request label Apr 27, 2026
Copy link
Copy Markdown
Member

@forelabs Sven Dunemann (forelabs) left a comment

Choose a reason for hiding this comment

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

ℹ️ Cache key changes for plain LocaleDownloadOpts fields (plain fields were previously omitted from the cache key)

Correctness fix, but it means any existing cache files with non-zero plain fields in LocaleDownloadOpts will produce different keys after upgrade. Not a big issue though, as this feature is new anyways.

Comment on lines +320 to +322
if response != nil && response.StatusCode == 304 {
return nil, response, nil
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A 304 is intercepted, the caller then re-checks response.StatusCode == 304. It works, but the responsibility boundary is blurry.

@forelabs Sven Dunemann (forelabs) merged commit 2bee38a into phrase:main Apr 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants