|
|
@ -550,6 +550,23 @@ async fn ensure_dir_exists<P: AsRef<std::path::Path>>(path: P) -> Result<(), Any |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async fn verify_dir_exists<P: AsRef<std::path::Path>>(path: P) -> Result<(), AnyError> { |
|
|
|
|
|
|
|
match tokio::fs::metadata(path.as_ref()).await { |
|
|
|
|
|
|
|
Ok(meta) if meta.is_dir() => Ok(()), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(meta) /* if ! meta.is_dir() */ => { |
|
|
|
|
|
|
|
debug_assert!( ! meta.is_dir()); |
|
|
|
|
|
|
|
Err(format!("path exists, but is not a directory: {:?}", path.as_ref()).into()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Err(e) if e.kind() == std::io::ErrorKind::NotFound => { |
|
|
|
|
|
|
|
Err(format!("path does not exist: {}", path.as_ref().display()).into()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Err(e) => Err(e.into()), |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async fn ensure_file_parent_dir_exists<P: AsRef<std::path::Path>>(path: P) -> Result<(), AnyError> { |
|
|
|
async fn ensure_file_parent_dir_exists<P: AsRef<std::path::Path>>(path: P) -> Result<(), AnyError> { |
|
|
|
if let Some(parent_dir) = path.as_ref().parent() { |
|
|
|
if let Some(parent_dir) = path.as_ref().parent() { |
|
|
|
ensure_dir_exists(parent_dir).await |
|
|
|
ensure_dir_exists(parent_dir).await |
|
|
@ -757,7 +774,10 @@ async fn run(config: Config) -> Result<(), AnyError> { |
|
|
|
tmp |
|
|
|
tmp |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
(_, Some(path)) => path, |
|
|
|
(_, Some(path)) => { |
|
|
|
|
|
|
|
verify_dir_exists(&path).await?; |
|
|
|
|
|
|
|
path |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_ => unreachable!(), |
|
|
|
_ => unreachable!(), |
|
|
|
}; |
|
|
|
}; |
|
|
|