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

Method create_shared_view

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

145 ///
146 /// Returns `ViewAlreadyExists` if the view already exists.
147 pub fn create_shared_view(&mut self, name: &str) -> Result<(), RepositoryError> {
148 ensure_workspace_dir(&self.dot_dir, name)?;
149
150 let mut txn = self
151 .pristine
152 .write_txn()
153 .map_err(|e| RepositoryError::Database(e.to_string()))?;
154
155 if txn
156 .get_view(name)
157 .map_err(|e| RepositoryError::Database(e.to_string()))?
158 .is_some()
159 {
160 return Err(RepositoryError::ViewAlreadyExists {
161 name: name.to_string(),
162 });
163 }
164
165 txn.create_view(name, ViewScope::Shared, None)
166 .map_err(|e| RepositoryError::Database(e.to_string()))?;
167
168 txn.commit()
169 .map_err(|e| RepositoryError::Database(e.to_string()))?;
170
171 Ok(())
172 }
173
174 /// Change a view's scope between Draft and Shared.
175 ///

Callers 4

runMethod · 0.80
run_asyncMethod · 0.80
run_asyncMethod · 0.80

Calls 5

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

Tested by

no test coverage detected