aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/admin_controller.rb2
-rw-r--r--app/controllers/application_controller.rb8
-rw-r--r--app/controllers/request_controller.rb7
3 files changed, 13 insertions, 4 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 7f8cfbd67..48e223cea 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -31,7 +31,7 @@ class AdminController < ApplicationController
# change the URL.
# * We could use expire_fragment with a Regexp, but it walks the whole
# cache which is insanely slow
- cache_subpath = File.join(self.cache_store.cache_path, "views/request/#{info_request.id}")
+ cache_subpath = File.join(self.cache_store.cache_path, foi_fragment_cache_all_for_request(info_request))
FileUtils.rm_rf(cache_subpath)
# Remove the database caches of body / attachment text (the attachment text
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 58266eb42..ac64bd1e6 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -253,6 +253,14 @@ class ApplicationController < ActionController::Base
expires_in max_age.minutes, :private => false
end
+ # Used to work out where to cache fragments
+ def foi_fragment_cache_path(param)
+ return url_for(param)
+ end
+ def foi_fragment_cache_all_for_request(info_request)
+ return "views/request/#{info_request.id}"
+ end
+
# URL generating functions are needed by all controllers (for redirects),
# views (for links) and mailers (for use in emails), so include them into
# all of all.
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index eaed31213..cca96214b 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -546,8 +546,9 @@ class RequestController < ApplicationController
around_filter :cache_attachments, :only => [ :get_attachment, :get_attachment_as_html ]
def cache_attachments
key = params.merge(:only_path => true)
- if cached = read_fragment(key)
- #if cached = 'zzz***zzz'
+ key_path = foi_fragment_cache_path(key)
+
+ if cached = read_fragment(key_path)
IncomingMessage # load global filename_to_mimetype XXX should move filename_to_mimetype to proper namespace
response.content_type = filename_to_mimetype(params[:file_name].join("/")) or 'application/octet-stream'
render_for_text(cached)
@@ -556,7 +557,7 @@ class RequestController < ApplicationController
yield
- write_fragment(key, response.body)
+ write_fragment(key_path, response.body)
end
def get_attachment