diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-08-22 16:23:59 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-09-16 14:03:10 +0100 |
commit | d3df251a8033b92ad89725a2a3fea91acdd7843d (patch) | |
tree | d37fd2ceb6bee4b58ed58a86bc41cca4e3e6cfaa /app/controllers/request_controller.rb | |
parent | c3d4859b0d02f772944042c2758b4c924871499f (diff) |
Move some download methods to InfoRequest.
Use send_file to send zips. Also adds 'all_can_view_all_correspondence?'
- is this request completely cachable, or do we need to cache different
versions for different levels of privilege?
Diffstat (limited to 'app/controllers/request_controller.rb')
-rw-r--r-- | app/controllers/request_controller.rb | 16 |
1 files changed, 6 insertions, 10 deletions
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 |