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

Method compute_delta_from_scratch

atomic-remote/src/sync.rs:692–729  ·  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

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

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