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

Method create_directory

atomic-repository/src/repository/switch.rs:343–365  ·  view source on GitHub ↗
(&mut self, path: &str)

Source from the content-addressed store, hash-verified

341
342impl super::materialize::MaterializationEffectExecutor for SwitchMaterializationExecutor<'_> {
343 fn create_directory(&mut self, path: &str) -> Result<bool, RepositoryError> {
344 if self
345 .effect_for_expected_new(path, |value| {
346 matches!(value, EffectValue::File(state) if state.kind == FileKind::Directory)
347 })
348 .is_none()
349 {
350 return match std::fs::symlink_metadata(self.repository.root().join(path)) {
351 Ok(metadata) if metadata.is_dir() => Ok(false),
352 Ok(_) => Err(RepositoryError::InvalidOperation {
353 message: format!("unleased non-directory entry blocks '{path}'"),
354 }),
355 Err(error) if error.kind() == std::io::ErrorKind::NotFound => {
356 Err(RepositoryError::InvalidOperation {
357 message: format!("switch operation omitted directory lease for '{path}'"),
358 })
359 }
360 Err(error) => Err(RepositoryError::Io(error)),
361 };
362 }
363 let pending = self.execute_directory(path)?;
364 self.record(pending)
365 }
366
367 fn write_file(&mut self, path: &str, content: &[u8]) -> Result<bool, RepositoryError> {
368 let content_hash = Hash::of(content);

Calls 7

is_noneMethod · 0.80
is_dirMethod · 0.80
execute_directoryMethod · 0.80
rootMethod · 0.45
kindMethod · 0.45
recordMethod · 0.45

Tested by

no test coverage detected