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,
remote: &HttpRemote,
missing: &[Hash],
stats: &mut CloneStats,
progress: &mut CloneProgress,
)
| 413 | /// Stops on the first download failure to maintain consistency (the |
| 414 | /// manifest apply would fail on the missing change anyway). |
| 415 | async fn download_missing_changes( |
| 416 | &self, |
| 417 | repo: &Repository, |
| 418 | remote: &HttpRemote, |
| 419 | missing: &[Hash], |
| 420 | stats: &mut CloneStats, |
| 421 | progress: &mut CloneProgress, |
| 422 | ) -> CliResult<()> { |
| 423 | if missing.is_empty() { |
| 424 | return Ok(()); |
| 425 | } |
| 426 | |
| 427 | print_blank(); |
| 428 | println!("Downloading {}:", format_count(missing.len(), "change")); |
| 429 | print_blank(); |
| 430 | |
| 431 | let progress_bar = create_progress_bar(missing.len() as u64, "Downloading changes"); |
| 432 | |
| 433 | for (i, hash) in missing.iter().enumerate() { |
| 434 | let hash_str = hash.to_base32(); |
| 435 | let hash_display = &hash_str[..12.min(hash_str.len())]; |
| 436 | |
| 437 | match remote.download_change(&hash_str).await { |
| 438 | Ok(data) => { |
| 439 | let data_len = data.len() as u64; |
| 440 | |
| 441 | // Save to local change store |
| 442 | match save_downloaded_change(repo, hash, data) { |
| 443 | Ok(()) => { |
| 444 | stats.record_change_downloaded(data_len); |
| 445 | progress.record_downloaded(); |
| 446 | println!( |
| 447 | " {} {}... ({}/{})", |
| 448 | success("✓"), |
| 449 | style_hash(hash_display), |
| 450 | i + 1, |
| 451 | missing.len() |
| 452 | ); |
| 453 | } |
| 454 | Err(e) => { |
| 455 | stats.record_failed(); |
| 456 | println!( |
| 457 | " {} {}... ({}/{}) save failed: {}", |
| 458 | error("✗"), |
| 459 | hash_display, |
| 460 | i + 1, |
| 461 | missing.len(), |
| 462 | e |
| 463 | ); |
| 464 | } |
| 465 | } |
| 466 | } |
| 467 | Err(e) => { |
| 468 | stats.record_failed(); |
| 469 | println!( |
| 470 | " {} {}... ({}/{}) download failed: {}", |
| 471 | error("✗"), |
| 472 | hash_display, |
no test coverage detected