ksud: ensure parent dir when create file
This commit is contained in:
@@ -285,8 +285,16 @@ impl StockMount {
|
|||||||
utils::ensure_dir_exists(&path)
|
utils::ensure_dir_exists(&path)
|
||||||
.with_context(|| format!("Failed to create dir: {}", path.display(),))?;
|
.with_context(|| format!("Failed to create dir: {}", path.display(),))?;
|
||||||
} else if dest.is_file() {
|
} else if dest.is_file() {
|
||||||
utils::ensure_file_exists(&path)
|
if !path.exists() {
|
||||||
.with_context(|| format!("Failed to create file: {}", path.display(),))?;
|
let parent = path
|
||||||
|
.parent()
|
||||||
|
.with_context(|| format!("Failed to get parent: {}", path.display()))?;
|
||||||
|
utils::ensure_dir_exists(parent).with_context(|| {
|
||||||
|
format!("Failed to create parent: {}", parent.display())
|
||||||
|
})?;
|
||||||
|
std::fs::File::create(&path)
|
||||||
|
.with_context(|| format!("Failed to create file: {}", path.display(),))?;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
bail!("unknown file type: {:?}", dest)
|
bail!("unknown file type: {:?}", dest)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user