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>,
)
| 729 | /// Downloads the entire changelist from position 0 and builds the |
| 730 | /// cache from scratch. |
| 731 | async fn compute_delta_from_scratch( |
| 732 | &mut self, |
| 733 | view: &str, |
| 734 | local_hashes: &HashSet<String>, |
| 735 | ) -> RemoteResult<RemoteDelta> { |
| 736 | debug!("sync: no cache, downloading full changelist"); |
| 737 | self.stats.from_scratch = true; |
| 738 | |
| 739 | let remote_entries = self.remote.get_changelist(view, 0).await?; |
| 740 | self.stats.changelist_entries_fetched = remote_entries.len(); |
| 741 | |
| 742 | let mut theirs_ge_dichotomy = Vec::new(); |
| 743 | let mut theirs_ge_dichotomy_set = HashSet::new(); |
| 744 | let mut to_download = Vec::new(); |
| 745 | |
| 746 | for entry in &remote_entries { |
| 747 | let node = entry.to_node(); |
| 748 | theirs_ge_dichotomy_set.insert(node.clone()); |
| 749 | theirs_ge_dichotomy.push((entry.sequence, node.clone())); |
| 750 | |
| 751 | if !local_hashes.contains(&entry.hash) { |
| 752 | to_download.push(node); |
| 753 | } |
| 754 | } |
| 755 | |
| 756 | // Seed the cache from the full changelist |
| 757 | *self.cache = RemoteState::from_changelist(&remote_entries); |
| 758 | |
| 759 | Ok(RemoteDelta { |
| 760 | to_download, |
| 761 | ours_ge_dichotomy: Vec::new(), |
| 762 | ours_ge_dichotomy_set: HashSet::new(), |
| 763 | theirs_ge_dichotomy, |
| 764 | theirs_ge_dichotomy_set, |
| 765 | remote_unrecords: Vec::new(), |
| 766 | divergence_point: 0, |
| 767 | }) |
| 768 | } |
| 769 | |
| 770 | // Convenience: Pull and Push |
| 771 |
no test coverage detected