
@@ -139,4 +141,17 @@ class StatsWorker STDERR.puts e.message end end + + def write_user_stats(result_root : String, define_files : Hash(String, JSON::Any)) + return nil unless result_root && File.exists?(result_root) + + define_files.each do |k, v| + if k.match (/^stats/) ^^^^^^^^^^^^^^^^^^^^^ one less indent if use next unless
不需要next,k没有匹配上自动进入下次循环了
next unless k.match (/^stats/)
+ Dir.mkdir("#{result_root}/stats") unless File.exists?("#{result_root}/stats") + File.open("#{result_root}/#{k}", "w+", File::Permissions.new(0o775)) do |file| + file.puts v + end + end
Dir.mkdir("#{result_root}/stats") unless File.exists?("#{result_root}/stats") File.open("#{result_root}/#{k}", "w+", File::Permissions.new(0o775)) do |file| file.puts v end
这里似乎没有变化? Thanks, Weitao
Thanks, Kaiyi
+ end + end end -- 2.23.0