From f57e765554cb496cb35b52064db866156304c690 Mon Sep 17 00:00:00 2001 From: Martin Krulis Date: Tue, 29 Sep 2020 21:13:27 +0200 Subject: [PATCH] Simplifying decompression of submission archives (since they will no longer have unnecessary sub-dir inside). --- src/job/job_evaluator.cpp | 30 +++-------------------- src/job/job_evaluator.h | 2 -- tests/testing_archives/valid_tar.tar | Bin 10240 -> 4096 bytes tests/testing_archives/valid_tar.tar.bz2 | Bin 273 -> 210 bytes tests/testing_archives/valid_tar.tar.gz | Bin 268 -> 216 bytes tests/testing_archives/valid_zip.zip | Bin 1002 -> 502 bytes 6 files changed, 4 insertions(+), 28 deletions(-) diff --git a/src/job/job_evaluator.cpp b/src/job/job_evaluator.cpp index 6b61a1df..396c554b 100644 --- a/src/job/job_evaluator.cpp +++ b/src/job/job_evaluator.cpp @@ -49,25 +49,15 @@ void job_evaluator::prepare_submission() { logger_->info("Preparing submission for usage..."); - // decompress downloaded archive + // decompress downloaded archive directly to source path (eval dir) try { - fs::create_directories(submission_path_); - archivator::decompress((archive_path_ / archive_name_).string(), submission_path_.string()); + fs::create_directories(source_path_); + archivator::decompress((archive_path_ / archive_name_).string(), source_path_.string()); + fs::permissions(source_path_, fs::add_perms | fs::group_write | fs::others_write); } catch (archive_exception &e) { throw job_exception("Downloaded submission cannot be decompressed: " + std::string(e.what())); } - // copy source codes to source code folder - try { - // stem().stem() is removing the .tar.bz2 ending (maybe working with just .zip ending too) - fs::path tmp_path = submission_path_ / archive_name_.stem().stem(); - // source_path_ is automaticaly created in copy_directory() - helpers::copy_directory(tmp_path, source_path_); - fs::permissions(source_path_, fs::add_perms | fs::group_write | fs::others_write); - } catch (helpers::filesystem_exception &e) { - throw job_exception("Error copying source files to source code path: " + std::string(e.what())); - } - try { fs::create_directories(results_path_); } catch (fs::filesystem_error &e) { @@ -149,7 +139,6 @@ void job_evaluator::run_job() void job_evaluator::init_submission_paths() { source_path_ = working_directory_ / "eval" / std::to_string(config_->get_worker_id()) / job_id_; - submission_path_ = working_directory_ / "submissions" / std::to_string(config_->get_worker_id()) / job_id_; archive_path_ = working_directory_ / "downloads" / std::to_string(config_->get_worker_id()) / job_id_; // set temporary directory for tasks in job job_temp_dir_ = working_directory_ / "temp" / std::to_string(config_->get_worker_id()) / job_id_; @@ -169,16 +158,6 @@ void job_evaluator::cleanup_submission() logger_->warn("Source code directory not cleaned properly: {}", e.what()); } - // delete submission decompressed directory - try { - if (fs::exists(submission_path_)) { - logger_->info("Cleaning up decompressed submission directory..."); - fs::remove_all(submission_path_); - } - } catch (fs::filesystem_error &e) { - logger_->warn("Submission directory not cleaned properly: {}", e.what()); - } - // delete downloaded archive directory try { if (fs::exists(archive_path_)) { @@ -218,7 +197,6 @@ void job_evaluator::cleanup_variables() archive_url_ = ""; archive_name_ = ""; archive_path_ = ""; - submission_path_ = ""; source_path_ = ""; results_path_ = ""; result_url_ = ""; diff --git a/src/job/job_evaluator.h b/src/job/job_evaluator.h index 901dd586..91d13ed7 100644 --- a/src/job/job_evaluator.h +++ b/src/job/job_evaluator.h @@ -133,8 +133,6 @@ class job_evaluator : public job_evaluator_interface fs::path archive_name_; /** Path in which downloaded archive is stored */ fs::path archive_path_; - /** Path in which downloaded decompressed submission is stored */ - fs::path submission_path_; /** Path only with source codes and job configuration, no subfolders */ fs::path source_path_; /** Results path in which result.yml and result.zip are stored */ diff --git a/tests/testing_archives/valid_tar.tar b/tests/testing_archives/valid_tar.tar index 3061d295295ee741ffca79bd4428657ae089dd06..0a1c2b6a18a7c4041a3f7a241b00d89688adea4a 100644 GIT binary patch literal 4096 zcmeH}-3r1m4265`Q}_g$Hfi!aol~5M!hS$}dW&Pj(F|ZASi28O`1rJxMnMulU{XG4g;CkyMufo7^{(BA%|$4cW6Eyi@3%{HKOg#6zkZjV zCliGdPw@S&v|&Qg7LD=zHE7Zb)^8=uxN-h24)TT0|M||HM%EFI0?kc(`}% z+FhLFC2RHyR9X1n&i+Rj|9>JW{!j3F-1T`Y?oS|erX@~U`2T1AoBi+Sz!aKoeEv%z JajB870v`l}L*f7c literal 10240 zcmeH~Sx&<+6h-~bD!c-C&*KKVg??8q2_mSpRfei!_1KltM2!S|;1t?xMRMXq9?pGJ z4q;Ojt2We6B3q-_ytN{Bn%JkF*a=Blc5^Z5o$DW7 zcW)0DNbq<+1P1?qzM}tA@BjAf{|x`1!wLue!xi=Sz5Y&lcZ&Zi=6}Th{1&hcA4RB< z0rHdnn=1_d-*oGu%JLhK>c1b?|0>o0Mr%U-KZnIk^p9rnQfQDtF7_A;wbB?(y_q?uGlUsRri zT#Wm*4+~(2Bdq7rvf$ZzOM)5`T;|sZ#|^_ki2`CY0$2*9*aRYSYFf|@VAKMMAOk{J z^~+#UEX_!G(Fg_tU^S3JRIo$QqX={JNzTMH+1x`-HR)iQUWhy80*L$!R7L@-6p!NW MNT&)C1op&-fKOLc3jhEB literal 273 zcmV+s0q*`nT4*^jL0KkKS*VVfkpKaR|AxVk06;(i|9}JlqX7SR-%tR6004nVFaa0= zfHct2qY;n|02&xz4Ky@p#AE|N28IZtAvA+z)B_=)G->G?d=C5JjV_`$ry$Zmr05kL zd0}+KjE+s@Yl7J|1(sYo0mNWHk=5-%sL*77N7K*Gb)Z}rck==pU7lV&A{PyyJ#rtVML1B9sE(MCsO@pL diff --git a/tests/testing_archives/valid_tar.tar.gz b/tests/testing_archives/valid_tar.tar.gz index aea73ba74fd4108eb220d93417a7c56354eaed7b..6b4bfc63de4b2918f2f3a96137191270dd440172 100644 GIT binary patch literal 216 zcmV;}04M(+iwFoihI3y40Cr()X=Gn?VR9~XVR8WNmQ4!6Fc5{a_7pvVPLj#Yc~Yxb z5rzJMc=}drtI~p-rY&^7P2g?v;Ny|xWt^nhPK5*j*tuvZZ&BK^MFtCm&)hLt<$|_) zQ|5)wqJFuRkT?G81>;xgvvU7FjPf7; z`{&j_8K&3%kwE-Uz|}tzpKa!@A=&{Bum4}S SeD|AN)TGffDEmKPO3#VO7t8H&8M-KdFuH*$RX_rC-yXS8RlSqWlI+6!sZ zl{7dsaq&`$ec9HJ=1q2+P;KS3DeERjU6~xO`OiPwQ=8-)UBJ$m2l?Ae{!UYz$A;Jm zNlB`?^XB=7hAwWYr_3Mhd=qpVNtEiR~`mWo&SCQ&N5;D2LJ#700000 S00000_>UiZ_zzwHC;$MZb%x3S diff --git a/tests/testing_archives/valid_zip.zip b/tests/testing_archives/valid_zip.zip index 03c2fd6eaf571998a3dab646c7a822a1d3df64b3..02bcc16f4ec297ee35abcfcd079d572e680c4b91 100644 GIT binary patch literal 502 zcmWIWW@Zs#U}9ik_^`q@5Ju!GNpHCZ=WPq{7{a(^N(#Ic8k3DFO622naB|bp+AKamxyc zTeRp1@J5)28M6@c7=b1&X>>s`4;s%vLqYM3$56}&hB*>s=p+