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

Method compute_delta_from_scratch

atomic-remote/src/sync.rs:731–768  ·  view source on GitHub ↗

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>,
    )

Source from the content-addressed store, hash-verified

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

Callers 1

compute_deltaMethod · 0.80

Calls 7

get_changelistMethod · 0.80
to_nodeMethod · 0.80
lenMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45
pushMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected