aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin_controller.rb3
-rw-r--r--app/controllers/application_controller.rb13
-rw-r--r--app/controllers/request_controller.rb16
3 files changed, 7 insertions, 25 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 0bccd3358..0d83c9251 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -29,8 +29,7 @@ class AdminController < ApplicationController
FileUtils.rm_rf(cache_subpath)
# Remove any download zips
- download_dir = request_download_zip_dir(info_request)
- FileUtils.rm_rf(download_dir)
+ FileUtils.rm_rf(info_request.download_zip_dir)
# Remove the database caches of body / attachment text (the attachment text
# one is after privacy rules are applied)
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 88b107861..902b43215 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -214,19 +214,6 @@ class ApplicationController < ActionController::Base
end
end
- def request_dirs(info_request)
- first_three_digits = info_request.id.to_s()[0..2]
- File.join(first_three_digits.to_s, info_request.id.to_s)
- end
-
- def request_download_zip_dir(info_request)
- File.join(download_zip_dir, "download", request_dirs(info_request))
- end
-
- def download_zip_dir()
- File.join(Rails.root, '/cache/zips/')
- end
-
# get the local locale
def locale_from_params(*args)
if params[:show_locale]
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 8b978cc01..e1fbb6a68 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -879,17 +879,13 @@ class RequestController < ApplicationController
if !@info_request.user_can_view?(@user)
return render_hidden
end
- @url_path = File.join("/download",
- request_dirs(@info_request),
- @info_request.last_update_hash,
- "#{params[:url_title]}.zip")
- file_path = File.expand_path(File.join(download_zip_dir(), @url_path))
- if !File.exists?(file_path)
- FileUtils.mkdir_p(File.dirname(file_path))
- make_request_zip(info_request, file_path)
- File.chmod(0644, file_path)
+ cache_file_path = @info_request.make_zip_cache_path(@user)
+ if !File.exists?(cache_file_path)
+ FileUtils.mkdir_p(File.dirname(cache_file_path))
+ make_request_zip(@info_request, cache_file_path)
+ File.chmod(0644, cache_file_path)
end
- redirect_to @url_path
+ send_file(cache_file_path, :filename => "#{@info_request.url_title}.zip")
end
end
end