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