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

Method acquire

rust/src/lock.rs:38–61  ·  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

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

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected