pub(crate) fn claim_take_dir(
dir: &Path,
stamp: u128,
) -> Result<(String, PathBuf)>Expand description
Claim dir/take-<stamp>/, advancing a millisecond per name already taken,
and answer the name and the directory it claimed.
The claim is the create_dir, not a probe before it. A name checked
with exists() and made with create_dir_all lets two writers stamped in
the same millisecond both pass the check and land in one directory, where
the later silently replaces the earlier’s wav and meta. create_dir is the
one call that fails on a taken name, and its AlreadyExists is the loop’s
next candidate.
Advancing the stamp rather than suffixing the name keeps the shape every
reader of a store directory goes by - take- followed by all digits (see
starts_take) - and the order the names sort in.
The parent has to exist. create_dir makes one directory, so a caller
whose store may not exist yet creates it first: capture_take and
store_read_aloud_at both do.