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

Method vault_store_entry

atomic-repository/src/repository/vault.rs:197–227  ·  view source on GitHub ↗

Store a pre-built vault entry. Also updates the manifest. This is a lower-level method for internal use and tests where the caller has already constructed a `VaultEntry`. For the common case prefer [`vault_store`](Self::vault_store) which accepts raw parameters.

(
        &self,
        path: &str,
        entry: &VaultEntry,
    )

Source from the content-addressed store, hash-verified

195 /// caller has already constructed a `VaultEntry`. For the common case
196 /// prefer [`vault_store`](Self::vault_store) which accepts raw parameters.
197 pub fn vault_store_entry(
198 &self,
199 path: &str,
200 entry: &VaultEntry,
201 ) -> Result<Hash, RepositoryError> {
202 let content_hash = Hash::from_bytes(entry.content_hash);
203
204 let mut txn = self
205 .pristine
206 .write_txn()
207 .map_err(|e| RepositoryError::Database(e.to_string()))?;
208 use atomic_core::pristine::{VaultMutTxnT, VaultTxnT};
209
210 txn.put_vault_entry(path, entry)
211 .map_err(|e| RepositoryError::Database(e.to_string()))?;
212
213 let now = chrono::Utc::now().to_rfc3339();
214 let mut manifest = txn
215 .get_vault_manifest()
216 .map_err(|e| RepositoryError::Database(e.to_string()))?;
217 update_manifest_for_store(&mut manifest, path, entry, &now);
218 txn.put_vault_manifest(&manifest)
219 .map_err(|e| RepositoryError::Database(e.to_string()))?;
220
221 txn.commit()
222 .map_err(|e| RepositoryError::Database(e.to_string()))?;
223
224 self.vault_auto_index(path);
225
226 Ok(content_hash)
227 }
228
229 /// Automatically index a vault entry into the KG and embed it.
230 ///

Callers 1

Calls 7

write_txnMethod · 0.80
put_vault_entryMethod · 0.80
put_vault_manifestMethod · 0.80
commitMethod · 0.80
vault_auto_indexMethod · 0.80
get_vault_manifestMethod · 0.45

Tested by 1