FI3WFMTSNVFWOQWSIWD64UCPRIS6MW4GOADOC6RXPHBSGZBYL5PAC
pub async fn mut_txn<P: AsRef<Path>>(file: P) -> Result<MutTxnLock, anyhow::Error> {
let cmd = std::env::args().next().unwrap();
let mut process = std::process::Command::new(&cmd)
.args(&["lock", file.as_ref().to_str().unwrap()])
.stdout(std::process::Stdio::piped())
.spawn()?;
async fn start_stream_if_needed(file: &Path) -> Result<UnixStream, std::io::Error> {
if let Ok(stream) = UnixStream::connect(file).await {
Ok(stream)
} else {
let cmd = std::env::args().next().unwrap();
let mut process = std::process::Command::new(&cmd)
.args(&["lock", file.to_str().unwrap()])
.stdout(std::process::Stdio::piped())
.spawn()?;
let s = process.stdout.as_mut().unwrap();
s.read(&mut [0u8])?;
UnixStream::connect(file).await
}
}
let s = process.stdout.as_mut().unwrap();
s.read(&mut [0u8])?;
let mut stream = UnixStream::connect(file).await?;
pub async fn mut_txn<P: AsRef<Path>>(file: P) -> Result<MutTxnLock, anyhow::Error> {
let mut stream = start_stream_if_needed(file.as_ref()).await?;
let cmd = std::env::args().next().unwrap();
std::process::Command::new(&cmd)
.args(&["lock", file.as_ref().to_str().unwrap()])
.spawn()?;
let mut stream = UnixStream::connect(file).await?;
let mut stream = start_stream_if_needed(file.as_ref()).await?;
stream.writable().await?;
let lock = Arc::new(self.path.with_extension("lock"));
std::fs::create_dir_all(lock.parent().unwrap())?;
let lockfile = OpenOptions::new()
.write(true)
.create(true)
.open(&lock.as_ref())?;
if lockfile.try_lock_exclusive().is_err() {
return Ok(());
if let Some(p) = self.path.parent() {
std::fs::create_dir_all(p)?