startup notification: create_dir_all parent dir, add context for io ops
This commit is contained in:
parent
f0b1e69100
commit
21a9552b0b
|
@ -392,8 +392,33 @@ async fn main_cli() -> Result<()> {
|
|||
|
||||
tracing::debug!("Startup notification via file at {startup_notification_file_path:?}");
|
||||
|
||||
let mut notification_file = File::create(&startup_notification_file_path).await?;
|
||||
notification_file.write_all(file_contents).await?;
|
||||
if let Some(parent_dir) = startup_notification_file_path.parent() {
|
||||
tokio::fs::create_dir_all(parent_dir)
|
||||
.await
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"failed to create parent directory for startup notification file path: {}",
|
||||
startup_notification_file_path.display()
|
||||
)
|
||||
})?;
|
||||
}
|
||||
let mut notification_file = File::create(&startup_notification_file_path)
|
||||
.await
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"failed to create startup notification file to path: {}",
|
||||
startup_notification_file_path.display()
|
||||
)
|
||||
})?;
|
||||
notification_file
|
||||
.write_all(file_contents)
|
||||
.await
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"failed to write startup notification file to path: {}",
|
||||
startup_notification_file_path.display()
|
||||
)
|
||||
})?;
|
||||
|
||||
tracing::debug!("Created startup notification file at {startup_notification_file_path:?}");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue