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,
)
| 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, |
no test coverage detected