5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'app/controllers/meribah/download_controller.rb', line 5
def index
yaml_path = nil
Meribah::MUTEX.synchronize do
if session[:meribah_files].nil? || session[:meribah_files].empty?
redirect_to '/404.html'
return
end
files = session[:meribah_files]
yaml_path = "#{Rails.root}/tmp/#{files.shift}"
session[:meribah_files] = files
unless File.exist? yaml_path
redirect_to '/404.html'
return
end
end
::Meribah::TEMPFILES.delete(yaml_path)
yaml_file = File.open(yaml_path)
path,options = YAML::load(yaml_file)
yaml_file.close
File::unlink(yaml_file)
unless File.exist? path
redirect_to '/404.html'
return
end
file = File.open(path,'rb')
data = file.read
file.close
File::unlink(path) if ::Meribah::TEMPFILES.delete(path) send_data data, options
end
|