Skip to content

Restrict update --sync pruning to entries missing on disk#3165

Merged
ChanTsune merged 4 commits into
mainfrom
cli/update/sync-prune-missing-on-disk
Jul 6, 2026
Merged

Restrict update --sync pruning to entries missing on disk#3165
ChanTsune merged 4 commits into
mainfrom
cli/update/sync-prune-missing-on-disk

Conversation

@ChanTsune

@ChanTsune ChanTsune commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Summary

update --sync now prunes an archive entry only when its path no longer exists on disk. Previously any entry absent from the collected set was pruned, so entries filtered out by --exclude/--include or time filters were deleted even though their files still exist.

Notes

  • --sync is a stable option, so this changes stable-surface behavior.
  • Ambiguous stat errors (e.g. PermissionDenied) keep the entry to avoid data loss; only NotFound/NotADirectory/InvalidFilename prune.
  • Names produced by -s/--transform/--strip-components do not correspond to filesystem paths and are still pruned, as before.
  • Stacked on Unify missing-time options into a single --missing-time option #3164.

Summary by CodeRabbit

  • Bug Fixes
    • --sync now avoids removing archive entries just because they were skipped by filters, as long as the source files still exist on disk.
    • Improved handling of missing-file checks to reduce accidental pruning when file access fails for reasons other than “not found.”
  • Tests
    • Added coverage for --sync with excluded files and time-based filters to confirm existing files remain in the archive.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@ChanTsune, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ff4b53ab-f3c7-4b2b-a046-4ad41933263b

📥 Commits

Reviewing files that changed from the base of the PR and between 5bc874d and 8b3731f.

📒 Files selected for processing (2)
  • cli/src/command/update.rs
  • cli/tests/cli/update/option_sync.rs
📝 Walkthrough

Walkthrough

Changes --sync pruning logic in run_update_archive to only prune archive entries when they are absent from disk, using a new exists_on_disk helper that treats specific IO errors as missing. Adds two integration tests validating this behavior.

Changes

Sync pruning fix

Layer / File(s) Summary
Sync pruning logic and disk-existence helper
cli/src/command/update.rs
Pruning during --sync now requires the entry to be absent on disk (checked via new exists_on_disk helper using symlink_metadata), rather than pruning unconditionally when sync is set; also reformats std imports.
Integration tests for sync pruning behavior
cli/tests/cli/update/option_sync.rs
Adds tests confirming excluded-but-existing files and files skipped due to --newer-mtime filtering remain in the archive after --sync.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change to update --sync pruning behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cli/update/sync-prune-missing-on-disk

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the --sync update behavior to only prune archive entries that no longer exist on disk, preventing entries filtered out by exclusions or time filters from being deleted. A helper function exists_on_disk is introduced along with corresponding integration tests. Feedback highlights a potential cross-platform data loss issue and MSRV compilation risk caused by matching io::ErrorKind::InvalidFilename in the exists_on_disk function, suggesting its removal.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread cli/src/command/update.rs
@github-actions github-actions Bot added cli This issue is about cli application break API braking change labels Jul 5, 2026
Base automatically changed from cli/time-filter/unify-missing-time to main July 6, 2026 01:16
ChanTsune added 2 commits July 6, 2026 10:17
Previously any archive entry absent from the collected set was pruned,
so entries excluded by --exclude/--include or time filters were deleted
even though their files still exist. --sync now realigns the archive to
the disk state only: an entry is pruned solely when its path no longer
exists on disk.
@ChanTsune
ChanTsune force-pushed the cli/update/sync-prune-missing-on-disk branch from 7e4a946 to 5bc874d Compare July 6, 2026 01:18
@github-actions github-actions Bot removed the break API braking change label Jul 6, 2026
@ChanTsune
ChanTsune merged commit e66adf1 into main Jul 6, 2026
114 of 115 checks passed
@ChanTsune
ChanTsune deleted the cli/update/sync-prune-missing-on-disk branch July 6, 2026 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli This issue is about cli application

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant