Skip to content

Commit cbf0703

Browse files
committed
⚗️ add @archive support in stdio subcommand
Redesign @archive inclusion to preserve CLI argument order exactly. The previous implementation separated filesystem paths and @Archives before processing, which lost the original ordering. Key changes: - Add ItemSource, ArchiveSource, CollectedItem types to core.rs - Add collect_items_from_sources for unified processing - Process arguments one by one, maintaining order - Support @- for reading archives from stdin - Detect stdin conflicts (input archive from stdin vs @-)
1 parent 17757b4 commit cbf0703

7 files changed

Lines changed: 1274 additions & 99 deletions

File tree

cli/src/command/append.rs

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ use crate::{
88
core::{
99
AclStrategy, CollectOptions, CollectedItem, CreateOptions, FflagsStrategy, KeepOptions,
1010
MacMetadataStrategy, PathFilter, PathTransformers, PathnameEditor,
11-
PermissionStrategyResolver, TimeFilterResolver, TimestampStrategyResolver,
12-
XattrStrategy, collect_items_from_paths, create_entry, entry_option,
11+
PermissionStrategyResolver, TimeFilterResolver, TimeFilters, TimestampStrategyResolver,
12+
XattrStrategy, collect_items_from_paths, drain_entry_results, entry_option,
1313
re::{bsd::SubstitutionRule, gnu::TransformRule},
14-
read_paths, read_paths_stdin,
14+
read_paths, read_paths_stdin, spawn_entry_results,
1515
},
1616
},
1717
utils::{PathPartExt, VCS_FILES, fs::HardlinkResolver},
@@ -460,35 +460,31 @@ fn append_to_archive(args: AppendCommand) -> anyhow::Result<()> {
460460
time_filters: &time_filters,
461461
};
462462
let mut resolver = HardlinkResolver::new(collect_options.follow_links);
463-
let target_items = collect_items_from_paths(&files, &collect_options, &mut resolver)?;
463+
let target_items = collect_items_from_paths(&files, &collect_options, &mut resolver)?
464+
.into_iter()
465+
.map(CollectedItem::Filesystem)
466+
.collect::<Vec<_>>();
464467

465-
run_append_archive(&create_options, archive, target_items)
468+
run_append_archive(
469+
&create_options,
470+
archive,
471+
target_items,
472+
&filter,
473+
&time_filters,
474+
password,
475+
)
466476
}
467477

468478
pub(crate) fn run_append_archive(
469479
create_options: &CreateOptions,
470480
mut archive: Archive<impl io::Write>,
471481
target_items: Vec<CollectedItem>,
482+
filter: &PathFilter<'_>,
483+
time_filters: &TimeFilters,
484+
password: Option<&[u8]>,
472485
) -> anyhow::Result<()> {
473-
let (tx, rx) = std::sync::mpsc::channel();
474-
rayon::scope_fifo(|s| {
475-
for item in target_items {
476-
let tx = tx.clone();
477-
s.spawn_fifo(move |_| {
478-
log::debug!("Adding: {}", item.path.display());
479-
tx.send(create_entry(&item, create_options))
480-
.unwrap_or_else(|e| log::error!("{e}: {}", item.path.display()));
481-
})
482-
}
483-
484-
drop(tx);
485-
});
486-
487-
for entry in rx.into_iter() {
488-
if let Some(entry) = entry? {
489-
archive.add_entry(entry)?;
490-
}
491-
}
486+
let rx = spawn_entry_results(target_items, create_options, filter, time_filters, password);
487+
drain_entry_results(rx, |entry| archive.add_entry(entry))?;
492488
archive.finalize()?;
493489
Ok(())
494490
}

0 commit comments

Comments
 (0)