MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / download_missing_changes

Method download_missing_changes

atomic-cli/src/commands/clone/command.rs:504–584  ·  view source on GitHub ↗

Download every change in `missing` and save it to the change store. Stops on the first download failure to maintain consistency (the manifest apply would fail on the missing change anyway).

(
        &self,
        repo: &Repository,
        change_objects: &HashMap<String, Vec<u8>>,
        missing: &[Hash],
        stats: &mut CloneStats,
        progress: &mut CloneProgress,
    )

Source from the content-addressed store, hash-verified

502 /// Stops on the first download failure to maintain consistency (the
503 /// manifest apply would fail on the missing change anyway).
504 fn download_missing_changes(
505 &self,
506 repo: &Repository,
507 change_objects: &HashMap<String, Vec<u8>>,
508 missing: &[Hash],
509 stats: &mut CloneStats,
510 progress: &mut CloneProgress,
511 ) -> CliResult<()> {
512 if missing.is_empty() {
513 return Ok(());
514 }
515
516 print_blank();
517 println!("Downloading {}:", format_count(missing.len(), "change"));
518 print_blank();
519
520 let progress_bar = create_progress_bar(missing.len() as u64, "Downloading changes");
521
522 for (i, hash) in missing.iter().enumerate() {
523 let hash_str = hash.to_base32();
524 let hash_display = &hash_str[..12.min(hash_str.len())];
525
526 match change_objects.get(&hash_str) {
527 Some(data) => {
528 let data_len = data.len() as u64;
529
530 // Save to local change store
531 match save_downloaded_change(repo, hash, Bytes::from(data.clone())) {
532 Ok(()) => {
533 stats.record_change_downloaded(data_len);
534 progress.record_downloaded();
535 println!(
536 " {} {}... ({}/{})",
537 success("✓"),
538 style_hash(hash_display),
539 i + 1,
540 missing.len()
541 );
542 }
543 Err(e) => {
544 stats.record_failed();
545 println!(
546 " {} {}... ({}/{}) save failed: {}",
547 error("✗"),
548 hash_display,
549 i + 1,
550 missing.len(),
551 e
552 );
553 }
554 }
555 }
556 None => {
557 stats.record_failed();
558 println!(
559 " {} {}... ({}/{}) not found on remote",
560 error("✗"),
561 hash_display,

Callers 2

run_asyncMethod · 0.80

Calls 13

print_blankFunction · 0.85
create_progress_barFunction · 0.85
finish_successFunction · 0.85
record_downloadedMethod · 0.80
save_downloaded_changeFunction · 0.70
getMethod · 0.65
is_emptyMethod · 0.45
lenMethod · 0.45
iterMethod · 0.45
to_base32Method · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected