Warn on duplicate update targets and avoid quadratic entry matching#3175
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe update matching in ChangesDuplicate target handling
Estimated code review effort: 2 (Simple) | ~15 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant run_update_archive
participant target_files_mapping
participant Archive
CLI->>run_update_archive: invoke update with source paths
run_update_archive->>target_files_mapping: build entry_name -> Option((idx, item))
target_files_mapping-->>run_update_archive: duplicate entry name detected
run_update_archive->>run_update_archive: warn about colliding source spellings
loop for each archive entry
run_update_archive->>target_files_mapping: get_mut(entry_name).and_then(Option::take)
target_files_mapping-->>run_update_archive: consumed item or None
run_update_archive->>Archive: apply matched update
end
run_update_archive->>target_files_mapping: into_values().flatten()
target_files_mapping-->>run_update_archive: remaining unconsumed entries
run_update_archive->>Archive: append remaining entries
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request optimizes the archive update process by changing the target files mapping from using shift_remove (which is O(n)) to using Option::take with get_mut (which is O(1)), avoiding quadratic complexity. It also introduces warnings when distinct source paths map to the same archive entry while remaining idempotent (and silent) when the exact same path is specified multiple times. Additionally, comprehensive integration tests have been added to verify these behaviors. There are no review comments to address, and I have no further feedback to provide.
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.
4725f66 to
573741b
Compare
Summary
Resolves two review leftovers from #3007 in
update's entry matching: a warning is now emitted when different source paths collapse onto the same archive entry name (identical-path duplicates from overlapping sources stay silent), and the matching loop is rewritten from O(N×M)shift_removeto O(1) lookups while preserving insertion order.Notes
compat bsdtar -upath.Refs #1547
Summary by CodeRabbit
Bug Fixes
Tests