Skip to content

Commit a6cfa25

Browse files
committed
ensure lock file's dir exists
1 parent 27babdf commit a6cfa25

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

clang-installer/src/utils.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! A utility module for path normalization.
22
use std::{
3-
fs::File,
3+
fs::{self, File, OpenOptions},
44
path::{Component, Path, PathBuf},
55
};
66

@@ -47,7 +47,10 @@ pub fn normalize_path(path: &Path) -> PathBuf {
4747
/// 2. deleting the file when done (if desired).
4848
pub fn lock_path(path: &Path) -> Result<File, std::io::Error> {
4949
let lock_path = path.with_added_extension("lock");
50-
let file_lock = std::fs::OpenOptions::new()
50+
if let Some(parent) = lock_path.parent() {
51+
fs::create_dir_all(parent)?;
52+
}
53+
let file_lock = OpenOptions::new()
5154
.read(true)
5255
.create(true)
5356
.open(&lock_path)?;

0 commit comments

Comments
 (0)