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

Method push

atomic-repository/src/tracking/tree_ops.rs:184–260  ·  view source on GitHub ↗
(&mut self, operation: TreeProjectionOperation)

Source from the content-addressed store, hash-verified

182 }
183
184 fn push(&mut self, operation: TreeProjectionOperation) -> Result<(), TreeProjectionError> {
185 let inode = match &operation {
186 TreeProjectionOperation::Add { inode, .. }
187 | TreeProjectionOperation::Delete { inode, .. }
188 | TreeProjectionOperation::Move { inode, .. }
189 | TreeProjectionOperation::Undelete { inode, .. }
190 | TreeProjectionOperation::DirectoryOccupancy { inode, .. }
191 | TreeProjectionOperation::DirectoryFlags { inode, .. } => *inode,
192 };
193 let entry = self.entries.entry(inode).or_default();
194 match operation {
195 TreeProjectionOperation::Add {
196 path,
197 position,
198 kind,
199 ..
200 } => {
201 if let (Some(existing), Some(position)) = (entry.binding, position) {
202 if existing != position {
203 return Err(TreeProjectionError::Conflict(format!(
204 "inode {} was assigned both {} and {}",
205 inode.get(),
206 existing,
207 position
208 )));
209 }
210 } else if position.is_some() {
211 entry.binding = position;
212 }
213 if let Some(existing) = entry.kind {
214 if existing != kind {
215 return Err(TreeProjectionError::Conflict(format!(
216 "inode {} was projected as both a file and a directory",
217 inode.get()
218 )));
219 }
220 }
221 entry.kind = Some(kind);
222 if let Some(path) = path {
223 entry.path = Some(Some(path));
224 }
225 }
226 TreeProjectionOperation::Delete { retire, .. } => {
227 entry.path = Some(None);
228
229 entry.retire |= retire;
230 }
231 TreeProjectionOperation::Move { path, .. } => {
232 entry.path = Some(Some(path));
233 }
234 TreeProjectionOperation::Undelete { path, kind, .. } => {
235 if let Some(existing) = entry.kind {
236 if existing != kind {
237 return Err(TreeProjectionError::Conflict(format!(
238 "inode {} was projected as both a file and a directory",
239 inode.get()
240 )));
241 }

Calls 3

ConflictClass · 0.85
explicit_emptyFunction · 0.85
explicit_with_childrenFunction · 0.85