From b3dbd762d9bc21cf48357fa50901e125b42becc0 Mon Sep 17 00:00:00 2001 From: iximeow Date: Mon, 26 Dec 2022 00:13:20 +0000 Subject: ... actual artifacts dir --- src/ci_driver.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/ci_driver.rs b/src/ci_driver.rs index 94e55a0..bf21047 100644 --- a/src/ci_driver.rs +++ b/src/ci_driver.rs @@ -31,8 +31,18 @@ use crate::sql::JobState; fn reserve_artifacts_dir(job: u64) -> std::io::Result { let mut path: PathBuf = "/root/ixi_ci_server/jobs/".into(); path.push(job.to_string()); - std::fs::create_dir(&path)?; - Ok(path) + match std::fs::create_dir(&path) { + Ok(()) => { + Ok(path) + }, + Err(e) => { + if e.kind() == std::io::ErrorKind::AlreadyExists { + Ok(path) + } else { + Err(e) + } + } + } } async fn activate_job(dbctx: Arc, job: &PendingJob, clients: &mut mpsc::Receiver) -> Result<(), String> { @@ -53,12 +63,11 @@ async fn activate_job(dbctx: Arc, job: &PendingJob, clients: &mut mpsc::R .query_row("select sha from commits where id=?1", [job.commit_id], |row| row.get(0)) .expect("can run query"); - let artifacts = PathBuf::from("/tmp"); - /* let artifacts: PathBuf = match &job.artifacts { Some(artifacts) => PathBuf::from(artifacts), None => reserve_artifacts_dir(job.id).expect("can reserve a directory for artifacts") }; + /* if job.run_host.as_ref() == None { eprintln!("need to find a host to run the job"); -- cgit v1.1