- 1985
/// unlike DefaultHasher (SipHash with randomly-seeded-but-toolchain-chosen - 1986
/// parameters). Session directories must remain reachable after toolchain - 1987
/// upgrades. - 1988
fn hash_cwd(cwd: &Path) -> String { - 1989
let mut h: u64 = 0xcbf2_9ce4_8422_2325; - 1990
for b in cwd.to_string_lossy().as_bytes() { - 1991
h ^= u64::from(*b); - 1992
h = h.wrapping_mul(0x0000_0100_0000_01b3); - 1993
} - 1994
format!("{h:016x}") - 1995
} - 1996
- 1997
#[cfg(all(test, unix))] - 1998
mod tests { - 1999
#![allow(clippy::unwrap_used, clippy::expect_used)] - 2000
use super::*; - 2001
- 2002
/// A child being spawned holds a duplicate of every open descriptor - 2003
/// until it execs; the duplicate here stands in for one. - 2004
#[test] - 2005
fn the_lock_lasts_exactly_as_long_as_the_handle() { - 2006
let dir = tempfile::tempdir().unwrap(); - 2007
let path = dir.path().join("session.jsonl"); - 2008
std::fs::write(&path, "").unwrap(); - 2009
- 2010
let log = SessionLog::open(path.clone()).unwrap(); - 2011
assert!(matches!( - 2012
SessionLog::open(path.clone()), - 2013
Err(SessionError::Locked(_)) - 2014
)); - 2015
- 2016
let duplicate = log.file.file.try_clone().unwrap(); - 2017
drop(log); - 2018
SessionLog::open(path).expect("the dropped handle's lock stayed with a duplicate"); - 2019
drop(duplicate); - 2020
} - 2021
} - 2022
Indexing the workspace…
Vakyartha documentation is discovering safe artifacts, anchors, and source references.