Skip to main content

ensure_private_directory

Function ensure_private_directory 

Source
pub fn ensure_private_directory(directory: &Path) -> Result<()>
Expand description

What: Create a private directory unless another process made it first. Why: Concurrent commits of one repository race to create the shared cli-git/shadow parents; whoever loses has nothing left to do. A path that exists as anything but a directory is still a failure.

In TS you’d write (pseudocode):

await mkdir(directory, { mode: 0o700 }).catch((error) => { if (error.code !== 'EEXIST') throw error; });