MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / acquire

Method acquire

rust/src/lock.rs:39–62  ·  view source on GitHub ↗

Acquire file lock to prevent race conditions accessing the cache folder by concurrent SM processes

(
        log: &Logger,
        target: &Path,
        single_file: Option<String>,
    )

Source from the content-addressed store, hash-verified

37impl Lock {
38 // Acquire file lock to prevent race conditions accessing the cache folder by concurrent SM processes
39 pub fn acquire(
40 log: &Logger,
41 target: &Path,
42 single_file: Option<String>,
43 ) -> Result<Self, Error> {
44 let lock_folder = if single_file.is_some() {
45 create_parent_path_if_not_exists(target)?;
46 target.parent().unwrap()
47 } else {
48 create_path_if_not_exists(target)?;
49 target
50 };
51 let path = lock_folder.join(LOCK_FILE);
52 let file = File::create(&path)?;
53
54 log.debug(format!("Acquiring lock: {}", path.display()));
55 file.lock_exclusive().unwrap_or_default();
56 set_lock_path(Some(path.to_path_buf()));
57
58 Ok(Self {
59 file: Some(file),
60 path,
61 })
62 }
63
64 pub fn release(&mut self) {
65 if let Some(file) = self.file.take() {

Callers

nothing calls this directly

Calls 6

createFunction · 0.85
set_lock_pathFunction · 0.85
parentMethod · 0.80
debugMethod · 0.45

Tested by

no test coverage detected