Skip to content

Commit

Permalink
Fix compiling failure while target folder is not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
slhmy committed Dec 30, 2023
1 parent 9514a12 commit 9119651
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion judge-core/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::error::JudgeCoreError;
use crate::utils::get_pathbuf_str;
use anyhow::anyhow;
use serde_derive::{Serialize, Deserialize};
use std::fmt;
use std::{fmt, fs};
use std::path::PathBuf;
use std::{process::Command, str::FromStr};

Expand Down Expand Up @@ -151,6 +151,10 @@ impl Compiler {
target_path_string
);

if let Some(target_parent) = target_path.parent() {
fs::create_dir_all(target_parent)?;
}

if PathBuf::from(target_path).exists() {
std::fs::remove_file(target_path)?;
}
Expand Down

0 comments on commit 9119651

Please sign in to comment.