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

Method create_shared_view

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

210 ///
211 /// Returns `ViewAlreadyExists` if the view already exists.
212 pub fn create_shared_view(&mut self, name: &str) -> Result<(), RepositoryError> {
213 ensure_workspace_dir(&self.dot_dir, name)?;
214
215 let mut txn = self
216 .pristine
217 .write_txn()
218 .map_err(|e| RepositoryError::Database(e.to_string()))?;
219
220 if txn
221 .get_view(name)
222 .map_err(|e| RepositoryError::Database(e.to_string()))?
223 .is_some()
224 {
225 return Err(RepositoryError::ViewAlreadyExists {
226 name: name.to_string(),
227 });
228 }
229
230 txn.create_view(name, ViewScope::Shared, None)
231 .map_err(|e| RepositoryError::Database(e.to_string()))?;
232
233 txn.commit()
234 .map_err(|e| RepositoryError::Database(e.to_string()))?;
235
236 Ok(())
237 }
238
239 /// Change a view's scope between Draft and Shared.
240 ///

Calls 5

ensure_workspace_dirFunction · 0.85
write_txnMethod · 0.80
commitMethod · 0.80
get_viewMethod · 0.45
create_viewMethod · 0.45