Skip to content

Commit 2f610f9

Browse files
authored
Fix: Create working directory if it doesn't exist (dora-rs#1066)
We forgot to create the working directory in a few cases in dora-rs#901. This PR fixes this by adding the proper `create_dir_all` calls. Alternative to dora-rs#1064
2 parents 2d780ee + 6073c9c commit 2f610f9

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

binaries/daemon/src/spawn.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ impl Spawner {
121121
node_config: NodeConfig,
122122
node_stderr_most_recent: Arc<ArrayQueue<String>>,
123123
) -> eyre::Result<PreparedNode> {
124+
std::fs::create_dir_all(&node_working_dir)
125+
.context("failed to create node working directory")?;
124126
let (command, error_msg) = match &node.kind {
125127
dora_core::descriptor::CoreNodeKind::Custom(n) => {
126128
let mut command =

libraries/core/src/build/build_command.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ pub fn run_build_command(
1515
envs: &Option<BTreeMap<String, EnvValue>>,
1616
stdout_tx: tokio::sync::mpsc::Sender<std::io::Result<String>>,
1717
) -> eyre::Result<()> {
18+
std::fs::create_dir_all(working_dir).context("failed to create working directory")?;
19+
1820
let lines = build.lines().collect::<Vec<_>>();
1921
for build_line in lines {
2022
let mut split = build_line.split_whitespace();

libraries/core/src/build/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,16 @@ async fn build_node(
119119
run_build_command(&build, &working_dir, uv, &node_env, stdout_tx)
120120
.context("build command failed")
121121
});
122-
tokio::spawn(async move {
122+
let stdout_task = tokio::spawn(async move {
123123
while let Some(line) = stdout.recv().await {
124124
logger
125125
.log_stdout(line.unwrap_or_else(|err| format!("io err: {}", err.kind())))
126126
.await;
127127
}
128128
});
129+
stdout_task.await?;
129130
task.await??;
131+
130132
Ok(())
131133
}
132134

0 commit comments

Comments
 (0)