Skip to content

Add --ignore-collisions flag to cache restore#526

Open
cchristous wants to merge 4 commits intosemaphoreci:masterfrom
cchristous:ignore-existing-cache-files
Open

Add --ignore-collisions flag to cache restore#526
cchristous wants to merge 4 commits intosemaphoreci:masterfrom
cchristous:ignore-existing-cache-files

Conversation

@cchristous
Copy link

@cchristous cchristous commented Dec 22, 2025

Summary

Adds an opt-in --ignore-collisions flag to cache restore that silently ignores file collisions.

cache restore --ignore-collisions [keys]

When enabled:

  • Existing files are preserved (not overwritten)
  • No error is raised when files already exist

Implementation

Handles platform differences in tar behavior:

  • GNU tar (Linux): uses --skip-old-files (silent, exit 0)
  • BSD tar (macOS): uses -k (silent, exit 0)
  • Native archiver: checks file existence and skips

Test plan

  • Unit tests pass on macOS (BSD tar)
  • Unit tests pass on Linux (GNU tar)
  • Manual testing with cache restore --ignore-collisions

@dexyk
Copy link
Contributor

dexyk commented Dec 24, 2025

/sem-approve

@cchristous cchristous changed the title silence file collision warnings in cache restore Add --ignore-collisions flag to cache restore Jan 29, 2026
@dexyk
Copy link
Contributor

dexyk commented Jan 29, 2026

/sem-approve

cchristous and others added 4 commits January 29, 2026 09:51
This adds an opt-in flag to silently ignore file collisions during
cache restore. When enabled, existing files are preserved rather than
overwritten, and no error is raised.

The implementation handles platform differences:
- GNU tar: uses --skip-old-files (silent, exit 0)
- BSD tar: uses -k (silent, exit 0)
- Native archiver: checks file existence and skips
- Cache isGNUTar() result using sync.Once to avoid repeated subprocess calls
- Align internal naming: SkipExisting → IgnoreCollisions
- Add assertion for restored file content in test

Co-Authored-By: Claude <noreply@anthropic.com>
@cchristous cchristous force-pushed the ignore-existing-cache-files branch from 9ca0802 to 64a7771 Compare January 29, 2026 14:53
@cchristous
Copy link
Author

@dexyk I don't think any of the failures are related to my changes. Could you confirm?

@cchristous cchristous marked this pull request as ready for review January 29, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants