Compute delta when we have no cached state (first sync). Downloads the entire changelist from position 0 and builds the cache from scratch.
(
&mut self,
view: &str,
local_hashes: &HashSet<String>,
)
| 690 | /// Downloads the entire changelist from position 0 and builds the |
| 691 | /// cache from scratch. |
| 692 | async fn compute_delta_from_scratch( |
| 693 | &mut self, |
| 694 | view: &str, |
| 695 | local_hashes: &HashSet<String>, |
| 696 | ) -> RemoteResult<RemoteDelta> { |
| 697 | debug!("sync: no cache, downloading full changelist"); |
| 698 | self.stats.from_scratch = true; |
| 699 | |
| 700 | let remote_entries = self.remote.get_changelist(view, 0).await?; |
| 701 | self.stats.changelist_entries_fetched = remote_entries.len(); |
| 702 | |
| 703 | let mut theirs_ge_dichotomy = Vec::new(); |
| 704 | let mut theirs_ge_dichotomy_set = HashSet::new(); |
| 705 | let mut to_download = Vec::new(); |
| 706 | |
| 707 | for entry in &remote_entries { |
| 708 | let node = entry.to_node(); |
| 709 | theirs_ge_dichotomy_set.insert(node.clone()); |
| 710 | theirs_ge_dichotomy.push((entry.sequence, node.clone())); |
| 711 | |
| 712 | if !local_hashes.contains(&entry.hash) { |
| 713 | to_download.push(node); |
| 714 | } |
| 715 | } |
| 716 | |
| 717 | // Seed the cache from the full changelist |
| 718 | *self.cache = RemoteState::from_changelist(&remote_entries); |
| 719 | |
| 720 | Ok(RemoteDelta { |
| 721 | to_download, |
| 722 | ours_ge_dichotomy: Vec::new(), |
| 723 | ours_ge_dichotomy_set: HashSet::new(), |
| 724 | theirs_ge_dichotomy, |
| 725 | theirs_ge_dichotomy_set, |
| 726 | remote_unrecords: Vec::new(), |
| 727 | divergence_point: 0, |
| 728 | }) |
| 729 | } |
| 730 | |
| 731 | // Convenience: Pull and Push |
| 732 |
no test coverage detected