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

Function acquire_owner_lock

atomic-cli/src/commands/agent/owner.rs:909–925  ·  view source on GitHub ↗
(dot_dir: &Path)

Source from the content-addressed store, hash-verified

907}
908
909fn acquire_owner_lock(dot_dir: &Path) -> anyhow::Result<File> {
910 let path = dot_dir.join(OWNER_LOCK_FILE);
911 let file = OpenOptions::new()
912 .create(true)
913 .truncate(false)
914 .read(true)
915 .write(true)
916 .open(&path)
917 .with_context(|| format!("failed to open owner lock {}", path.display()))?;
918 file.try_lock_exclusive().map_err(|error| {
919 anyhow!(
920 "another database owner already holds {}: {error}",
921 path.display()
922 )
923 })?;
924 Ok(file)
925}
926
927fn owner_failpoint(name: &str) {
928 if std::env::var("ATOMIC_OWNER_FAILPOINT").ok().as_deref() != Some(name) {

Callers 1

serveFunction · 0.85

Calls 5

truncateMethod · 0.80
with_contextMethod · 0.45
openMethod · 0.45
writeMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected