diff options
author | Francis Irving <francis@mysociety.org> | 2010-05-20 09:20:49 +0100 |
---|---|---|
committer | Francis Irving <francis@mysociety.org> | 2010-05-20 09:20:49 +0100 |
commit | 7572c232bf59e9700c526bfbba7d5ef262a07f63 (patch) | |
tree | 27f186176e9108294a081e972ce749702ed111d6 /app/controllers/request_controller.rb | |
parent | 5f1539c21005463164b626f51a235f48e1ff254a (diff) |
Use atomic write for making cache files.
Diffstat (limited to 'app/controllers/request_controller.rb')
-rw-r--r-- | app/controllers/request_controller.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 11e313caa..efb858adc 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -563,7 +563,9 @@ class RequestController < ApplicationController # which adds a header, so isnt compatible with images that have been # extracted elsewhere from PDFs) FileUtils.mkdir_p(File.dirname(key_path)) - File.open(key_path, 'wb') {|f| f.write(response.body) } + File.atomic_write(key_path) do |f| + f.write(response.body) + end end def get_attachment |