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

Method hold_sandbox_changes

atomic-repository/src/repository/remote_cache.rs:825–846  ·  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

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