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

Method create_shared_view

atomic-repository/src/repository/views.rs:219–250  ·  view source on GitHub ↗

Create a new Shared view with no parent. Changes inserted into a Shared view go into the global `GRAPH` table and are permanently visible to all views. This is the correct scope to use for server-side push targets, where changes must be universally visible regardless of which run or request inserts them. Returns `ViewAlreadyExists` if the view already exists.

(&mut self, name: &str)

Source from the content-addressed store, hash-verified

217 ///
218 /// Returns `ViewAlreadyExists` if the view already exists.
219 pub fn create_shared_view(&mut self, name: &str) -> Result<(), RepositoryError> {
220 let _review_boundary = self.review_evidence_lock()?;
221 self.ensure_project_identity(atomic_core::kg::project_id::MintReason::Upgrade)?;
222 ensure_workspace_dir(&self.dot_dir, name)?;
223
224 let mut txn = self
225 .pristine
226 .write_txn()
227 .map_err(|e| RepositoryError::Database(e.to_string()))?;
228
229 if txn
230 .get_view(name)
231 .map_err(|e| RepositoryError::Database(e.to_string()))?
232 .is_some()
233 {
234 return Err(RepositoryError::ViewAlreadyExists {
235 name: name.to_string(),
236 });
237 }
238
239 txn.create_view(name, ViewScope::Shared, None)
240 .map_err(|e| RepositoryError::Database(e.to_string()))?;
241
242 if txn.kg_writes_enabled()? {
243 self.project_view_kg(&mut txn)?;
244 }
245
246 txn.commit()
247 .map_err(|e| RepositoryError::Database(e.to_string()))?;
248
249 Ok(())
250 }
251
252 /// Change a view's scope between Draft and Shared.
253 ///

Calls 9

ensure_workspace_dirFunction · 0.85
review_evidence_lockMethod · 0.80
write_txnMethod · 0.80
kg_writes_enabledMethod · 0.80
project_view_kgMethod · 0.80
get_viewMethod · 0.45
create_viewMethod · 0.45
commitMethod · 0.45