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

Method hold_sandbox_changes

atomic-repository/src/repository/remote_cache.rs:820–841  ·  view source on GitHub ↗

Cache side: keep change files the owner sent — each only if its bytes hash to what it claims.

(&self, changes: &[ChangeFile])

Source from the content-addressed store, hash-verified

818 /// Cache side: keep change files the owner sent — each only if its
819 /// bytes hash to what it claims.
820 pub fn hold_sandbox_changes(&self, changes: &[ChangeFile]) -> Result<(), RepositoryError> {
821 use atomic_core::types::Base32;
822 for (hash, bytes) in changes {
823 let (change, computed) = atomic_core::change::Change::deserialize(&mut &bytes[..])
824 .map_err(|e| RepositoryError::Database(e.to_string()))?;
825 if computed != *hash {
826 return Err(RepositoryError::Database(format!(
827 "the owner sent {} as {}",
828 computed.to_base32(),
829 hash.to_base32()
830 )));
831 }
832 self.save_change_bytes(hash, bytes, &change)?;
833 let mut txn = self.pristine.write_txn().map_err(db)?;
834 let id = txn.get_internal(hash).map_err(db)?.ok_or_else(|| {
835 RepositoryError::Database(format!("owner sent unregistered change {hash}"))
836 })?;
837 txn.put_change_deps(id, change.dependencies()).map_err(db)?;
838 txn.commit().map_err(db)?;
839 }
840 Ok(())
841 }
842
843 /// In a remote sandbox: load what reading or recording the working
844 /// tree needs from the owner (see [`Repository::sandbox_slice_inodes`]).

Callers 2

fetch_changesFunction · 0.80

Calls 7

save_change_bytesMethod · 0.80
write_txnMethod · 0.80
put_change_depsMethod · 0.80
deserializeFunction · 0.70
get_internalMethod · 0.45
dependenciesMethod · 0.45
commitMethod · 0.45

Tested by 1

fetch_changesFunction · 0.64