Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/judge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ use tokio::{
fs,
io::{AsyncReadExt, AsyncWriteExt},
};
use uuid::Uuid;

use crate::{Language, Metrics, Resource, Sandbox, Verdict, util};
use crate::{Language, Metrics, Resource, Sandbox, Verdict};

const MAIN: &str = "main";
const CHECKER: &str = "checker";
Expand Down Expand Up @@ -42,7 +43,7 @@ impl Judge<Created> {
#[builder(default)] resource: Resource,
#[builder(default)] time_limit: Duration,
) -> io::Result<Judge<Created>> {
let project_path = env::temp_dir().join(util::random(main.content).to_string());
let project_path = env::temp_dir().join(Uuid::new_v4().to_string());
fs::create_dir(&project_path).await?;

let main_path = project_path
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ mod judge;
pub mod language;
mod metrics;
mod sandbox;
mod util;

pub use judge::*;
pub use language::Language;
Expand Down
5 changes: 2 additions & 3 deletions src/sandbox/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use std::{io, time::Duration};

use byte_unit::Byte;
use cgroups_rs::fs::{Cgroup, cgroup_builder::CgroupBuilder, hierarchies};

use crate::util;
use uuid::Uuid;

const PREFIX: &str = "judge";

Expand All @@ -28,7 +27,7 @@ impl TryFrom<Resource> for Cgroup {
type Error = io::Error;

fn try_from(resource: Resource) -> Result<Self, Self::Error> {
let builder = CgroupBuilder::new(&format!("{}/{}", PREFIX, util::random(resource)));
let builder = CgroupBuilder::new(&format!("{}/{}", PREFIX, Uuid::new_v4()));

let memory = resource.memory.as_u64() as i64;
let builder = builder
Expand Down
11 changes: 0 additions & 11 deletions src/util.rs

This file was deleted.