-
-
Notifications
You must be signed in to change notification settings - Fork 2
Fix critical bug in CLI update command and stabilize it #3007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,7 +22,7 @@ use crate::{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use clap::{ArgGroup, Parser, ValueHint}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use indexmap::IndexMap; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use pna::{Archive, EntryName, Metadata, prelude::*}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use pna::{Archive, Metadata, prelude::*}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use std::{env, fs, io, path::PathBuf}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[derive(Parser, Clone, Debug)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -583,7 +583,12 @@ where | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| let mut target_files_mapping = target_items | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .into_iter() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .enumerate() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .map(|(idx, item)| (EntryName::from_lossy(&item.path), (idx, item))) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .filter_map(|(idx, item)| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| create_options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .pathname_editor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .edit_entry_name(&item.path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .map(|name| (name, (idx, item))) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .collect::<IndexMap<_, _>>(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of
Comment on lines
583
to
592
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Detect transformed-name collisions instead of silently overwriting. This direct Suggested fix- let mut target_files_mapping = target_items
- .into_iter()
- .enumerate()
- .filter_map(|(idx, item)| {
- create_options
- .pathname_editor
- .edit_entry_name(&item.path)
- .map(|name| (name, (idx, item)))
- })
- .collect::<IndexMap<_, _>>();
+ let mut target_files_mapping = IndexMap::new();
+ for (idx, item) in target_items.into_iter().enumerate() {
+ let Some(name) = create_options.pathname_editor.edit_entry_name(&item.path) else {
+ continue;
+ };
+ if let Some((_, prev_item)) = target_files_mapping.get(&name) {
+ anyhow::bail!(
+ "multiple input paths map to the same archive entry '{}': '{}' and '{}'",
+ name,
+ prev_item.path.display(),
+ item.path.display()
+ );
+ }
+ target_files_mapping.insert(name, (idx, item));
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rayon::scope_fifo(|s| -> anyhow::Result<()> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While updating the imports and stabilizing the
updatecommand, note that thearchive_missing_ctimefield (defined at line 280) is currently unused in theupdate_archiveandrun_update_archivefunctions. Since the staleness check inis_newer_than_archiveonly utilizes modification time (mtime), this flag should either be integrated into the logic or removed to avoid providing a non-functional CLI option.