Skip to content

Commit

Permalink
Delete all files in tmp folder in cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
hermanzdosilovic committed Jun 16, 2019
1 parent 7fdca3c commit 50ee4db
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/jobs/isolate_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class IsolateJob < ApplicationJob
STDERR_FILE = 'stderr.txt'
META_FILE = 'meta.txt'

attr_reader :submission, :workdir, :box, :cgroups, :source, :stdin, :stdout, :stderr,
:meta, :parsed_meta, :id
attr_reader :submission, :workdir, :box, :tmp, :cgroups, :source,
:stdin, :stdout, :stderr, :meta, :parsed_meta, :id

def perform(submission)
@submission = submission
Expand Down Expand Up @@ -49,6 +49,7 @@ def init
@cgroups = (submission.enable_per_process_and_thread_time_limit | submission.enable_per_process_and_thread_memory_limit ? "--cg" : "")
@workdir = `isolate #{cgroups} -b #{id} --init`.chomp
@box = workdir + "/box/"
@tmp = workdir + "/tmp/"
@source = box + submission.language.source_file
@stdin = workdir + "/" + STDIN_FILE
@stdout = workdir + "/" + STDOUT_FILE
Expand Down Expand Up @@ -155,7 +156,7 @@ def verify
end

def clean
`sudo rm -rf #{box}/*` # Remove all files from the box before doing cleanup with isolate.
`sudo rm -rf #{box}/* #{tmp}/*` # Remove all files from the box before doing cleanup with isolate.
`sudo rm -rf #{stdin} #{stdout} #{stderr} #{meta}`
`isolate #{cgroups} -b #{id} --cleanup`
end
Expand Down

0 comments on commit 50ee4db

Please sign in to comment.