From eddc4efdc0cb8766e9fc7b9e423b1ac340551490 Mon Sep 17 00:00:00 2001 From: fer22f <fer22f@gmail.com> Date: Sun, 5 Nov 2023 23:33:47 -0300 Subject: [PATCH] Fix checker using the TL and giving WA --- alvokanto/src/main.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/alvokanto/src/main.rs b/alvokanto/src/main.rs index 2a09bc4..e6a60aa 100644 --- a/alvokanto/src/main.rs +++ b/alvokanto/src/main.rs @@ -381,7 +381,7 @@ fn judge( let judge_start_instant = Local::now().naive_utc(); - let mut binary_file = request.source_text.as_bytes().to_vec(); + let mut binary_bytes = request.source_text.as_bytes().to_vec(); if let Compile::Command(transform, command, _) = &language.compile { isolate::reset(isolate_executable_path, isolate_box.id).expect("Reset failed"); @@ -450,7 +450,7 @@ fn judge( }; } - binary_file = fs::read( + binary_bytes = fs::read( isolate_box.path.join( language .run @@ -505,7 +505,7 @@ fn judge( let mut perms = file.metadata().unwrap().permissions(); perms.set_mode(0o755); file.set_permissions(perms).unwrap(); - file.write_all(&binary_file).unwrap(); + file.write_all(&binary_bytes).unwrap(); } let execute_stats = isolate::execute( isolate_executable_path, @@ -540,8 +540,12 @@ fn judge( break; } + let output_bytes = fs::read(&execute_stats.stdout_path).unwrap(); isolate::reset(isolate_executable_path, isolate_box.id).expect("Reset failed"); - fs::copy(&execute_stats.stdout_path, isolate_box.path.join("stdin")).expect("Copy"); + { + let mut file = File::create(isolate_box.path.join("stdin")).unwrap(); + file.write_all(&output_bytes).unwrap(); + } last_execute_stats = Some(execute_stats); // TODO: Support non-compile based languages -- GitLab