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

Method download_missing_changes

atomic-cli/src/commands/clone/command.rs:620–700  ·  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

618 /// Stops on the first download failure to maintain consistency (the
619 /// manifest apply would fail on the missing change anyway).
620 fn download_missing_changes(
621 &self,
622 repo: &Repository,
623 change_objects: &HashMap<String, Vec<u8>>,
624 missing: &[Hash],
625 stats: &mut CloneStats,
626 progress: &mut CloneProgress,
627 ) -> CliResult<()> {
628 if missing.is_empty() {
629 return Ok(());
630 }
631
632 print_blank();
633 println!("Downloading {}:", format_count(missing.len(), "change"));
634 print_blank();
635
636 let progress_bar = create_progress_bar(missing.len() as u64, "Downloading changes");
637
638 for (i, hash) in missing.iter().enumerate() {
639 let hash_str = hash.to_base32();
640 let hash_display = &hash_str[..12.min(hash_str.len())];
641
642 match change_objects.get(&hash_str) {
643 Some(data) => {
644 let data_len = data.len() as u64;
645
646 // Save to local change store
647 match save_downloaded_change(repo, hash, Bytes::from(data.clone())) {
648 Ok(()) => {
649 stats.record_change_downloaded(data_len);
650 progress.record_downloaded();
651 println!(
652 " {} {}... ({}/{})",
653 success("✓"),
654 style_hash(hash_display),
655 i + 1,
656 missing.len()
657 );
658 }
659 Err(e) => {
660 stats.record_failed();
661 println!(
662 " {} {}... ({}/{}) save failed: {}",
663 error("✗"),
664 hash_display,
665 i + 1,
666 missing.len(),
667 e
668 );
669 }
670 }
671 }
672 None => {
673 stats.record_failed();
674 println!(
675 " {} {}... ({}/{}) not found on remote",
676 error("✗"),
677 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