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

Method create_shared_view

atomic-repository/src/repository/views.rs:218–248  ·  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

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

Calls 8

ensure_workspace_dirFunction · 0.85
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