Skip to content

Commit

Permalink
fix: minor race condition creating directories
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed May 25, 2024
1 parent 804d771 commit 23db391
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ pub fn create(path: &Path) -> Result<File> {
}

pub fn create_dir_all<P: AsRef<Path>>(path: P) -> Result<()> {
static LOCK: Lazy<Mutex<u8>> = Lazy::new(Default::default);
let _lock = LOCK.lock().unwrap();

let path = path.as_ref();
if !path.exists() {
trace!("mkdir -p {}", display_path(path));
Expand Down Expand Up @@ -404,9 +407,10 @@ pub fn unzip(archive: &Path, dest: &Path) -> Result<()> {

#[cfg(test)]
mod tests {
use crate::test::reset;
use std::ops::Deref;

use crate::test::reset;

use super::*;

#[test]
Expand Down

0 comments on commit 23db391

Please sign in to comment.