Description:
locks dir based on temp file, does not copy dir when copying scripts, added proper rescue for ln_s
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r103:933325ce824a - - 4 files changed: 4 inserted, 3 deleted
@@ -22,13 +22,13 | |||||
|
22 | @usage_filename = usage_filename |
|
22 | @usage_filename = usage_filename |
|
23 | end |
|
23 | end |
|
24 |
|
24 | ||
|
25 | # Check if someone has initialized the dir. If not, call block. |
|
25 | # Check if someone has initialized the dir. If not, call block. |
|
26 |
|
26 | ||
|
27 | def setup # :yields: block |
|
27 | def setup # :yields: block |
|
28 | - dir = File.new(@dir_name) |
|
28 | + dir = File.new(@dir_name + '/lockfile',"w+") |
|
29 | dir.flock(File::LOCK_EX) |
|
29 | dir.flock(File::LOCK_EX) |
|
30 | begin |
|
30 | begin |
|
31 | counter_filename = get_counter_filename |
|
31 | counter_filename = get_counter_filename |
|
32 | if File.exist? counter_filename |
|
32 | if File.exist? counter_filename |
|
33 | # someone is here |
|
33 | # someone is here |
|
34 | f = File.new(counter_filename,"r+") |
|
34 | f = File.new(counter_filename,"r+") |
@@ -133,12 +133,13 | |||||
|
133 | scripts = Dir[std_script_dir + '/*'] |
|
133 | scripts = Dir[std_script_dir + '/*'] |
|
134 |
|
134 | ||
|
135 | copied = [] |
|
135 | copied = [] |
|
136 |
|
136 | ||
|
137 | scripts.each do |s| |
|
137 | scripts.each do |s| |
|
138 | fname = File.basename(s) |
|
138 | fname = File.basename(s) |
|
|
139 | + next if FileTest.directory?(s) | ||
|
139 | if !FileTest.exist?("#{script_dir}/#{fname}") |
|
140 | if !FileTest.exist?("#{script_dir}/#{fname}") |
|
140 | copied << fname |
|
141 | copied << fname |
|
141 | FileUtils.cp(s, "#{script_dir}") |
|
142 | FileUtils.cp(s, "#{script_dir}") |
|
142 | end |
|
143 | end |
|
143 | end |
|
144 | end |
|
144 |
|
145 |
@@ -5,13 +5,13 | |||||
|
5 |
|
5 | ||
|
6 | module Grader |
|
6 | module Grader |
|
7 |
|
7 | ||
|
8 | def self.link_or_copy(src, des) |
|
8 | def self.link_or_copy(src, des) |
|
9 | begin |
|
9 | begin |
|
10 | FileUtils.ln_s(src, des) |
|
10 | FileUtils.ln_s(src, des) |
|
11 | - rescue |
|
11 | + rescue NotImplementedError |
|
12 | FileUtils.cp(src,des) |
|
12 | FileUtils.cp(src,des) |
|
13 | end |
|
13 | end |
|
14 | end |
|
14 | end |
|
15 |
|
15 | ||
|
16 | def self.call_and_log(error_message) |
|
16 | def self.call_and_log(error_message) |
|
17 | begin |
|
17 | begin |
You need to be logged in to leave comments.
Login now