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

Function write_atomic_gitlink

atomic-repository/src/repository/operation.rs:5088–5105  ·  view source on GitHub ↗
(path: &Path, object_id: &[u8], mode: u32)

Source from the content-addressed store, hash-verified

5086}
5087
5088fn write_atomic_gitlink(path: &Path, object_id: &[u8], mode: u32) -> Result<(), RepositoryError> {
5089 let parent = path
5090 .parent()
5091 .ok_or_else(|| RepositoryError::InvalidOperation {
5092 message: format!("cannot replace gitlink without parent: {}", path.display()),
5093 })?;
5094 fs::create_dir_all(parent)?;
5095 let staging = tempfile::Builder::new()
5096 .prefix(".atomic-gitlink-")
5097 .tempdir_in(parent)?;
5098 let prepared = staging.path().join(BACKUP_VALUE);
5099 fs::create_dir(&prepared)?;
5100 write_new_synced(&prepared.join(".git"), object_id)?;
5101 set_mode(&prepared, mode)?;
5102 remove_filesystem_effect_path(path)?;
5103 fs::rename(&prepared, path)?;
5104 sync_directory(parent)
5105}
5106
5107fn write_atomic_regular_from_file(
5108 path: &Path,

Callers 1

Calls 7

write_new_syncedFunction · 0.85
sync_directoryFunction · 0.85
parentMethod · 0.80
set_modeFunction · 0.70
prefixMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected