Skip to content

Commit df7269f

Browse files
committed
Include root hash in the temp dir
That way you can get from one ticket and resume with another ticket, provided they refer to the same collection
1 parent 79ea709 commit df7269f

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sendme"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
edition = "2021"
55
authors = ["Rüdiger Klaehn <[email protected]>", "n0 team"]
66
keywords = ["scp", "sftp", "network", "p2p", "holepunching"]

src/main.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -585,13 +585,16 @@ pub async fn show_download_progress(
585585
}
586586

587587
async fn get(args: GetArgs) -> anyhow::Result<()> {
588+
let ticket = args.ticket;
589+
let addr = ticket.node_addr().clone();
588590
let secret_key = get_or_create_secret()?;
589591
let endpoint = MagicEndpoint::builder()
590592
.alpns(vec![])
591593
.secret_key(secret_key)
592594
.bind(args.common.magic_port)
593595
.await?;
594-
let iroh_data_dir = std::env::current_dir()?.join(".sendme-get");
596+
let dir_name = format!(".sendme-get-{}", ticket.hash().to_hex());
597+
let iroh_data_dir = std::env::current_dir()?.join(dir_name);
595598
let rt = iroh_bytes::util::runtime::Handle::from_current(1)?;
596599
let db = iroh_bytes::store::flat::Store::load(
597600
iroh_data_dir.clone(),
@@ -601,10 +604,9 @@ async fn get(args: GetArgs) -> anyhow::Result<()> {
601604
)
602605
.await?;
603606
let mp = MultiProgress::new();
604-
let ticket = args.ticket;
605-
let addr = ticket.node_addr().clone();
606607
let connect_progress = mp.add(ProgressBar::hidden());
607608
connect_progress.set_draw_target(ProgressDrawTarget::stderr());
609+
connect_progress.set_style(ProgressStyle::default_spinner());
608610
connect_progress.set_message(format!("connecting to {}", addr.node_id));
609611
let connection = endpoint.connect(addr, &iroh_bytes::protocol::ALPN).await?;
610612
let hash_and_format = HashAndFormat {
@@ -621,12 +623,19 @@ async fn get(args: GetArgs) -> anyhow::Result<()> {
621623
let payload_size = sizes.iter().skip(1).sum::<u64>();
622624
eprintln!("getting {} blobs, {}", sizes.len(), HumanBytes(total_size));
623625
eprintln!(
624-
"getting {} files, {}",
626+
"getting collection {} {} files, {}",
627+
print_hash(ticket.hash(), args.common.format),
625628
total_files,
626629
HumanBytes(payload_size)
627630
);
628631
let _task = tokio::spawn(show_download_progress(recv.into_stream(), total_size));
629632
let _stats = get::get(&db, connection, &hash_and_format, progress).await?;
633+
if args.common.verbose > 0 {
634+
let collection = Collection::load(&db, &hash_and_format.hash).await?;
635+
for (name, hash) in collection.iter() {
636+
println!(" {} {name}", print_hash(hash, args.common.format));
637+
}
638+
}
630639
export(db, hash_and_format).await?;
631640
std::fs::remove_dir_all(iroh_data_dir)?;
632641
Ok(())

0 commit comments

Comments
 (0)