diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-02-16 19:58:40 +0100 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-02-17 22:23:31 +0100 |
commit | d2ebdf664b42d4fac6b2e060ef79aa9fe0b0e72d (patch) | |
tree | 061aa99c9a95b506a4ee665c25bd1d83a467c46f /app/controllers/files_controller.rb | |
parent | 192e7306626e073a5e6fb3b41d69f0e3fddb0821 (diff) | |
download | gitlab-ce-d2ebdf664b42d4fac6b2e060ef79aa9fe0b0e72d.tar.gz |
Refactor.
Diffstat (limited to 'app/controllers/files_controller.rb')
-rw-r--r-- | app/controllers/files_controller.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 15523cbc2e7..267239b7b84 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -3,18 +3,21 @@ class FilesController < ApplicationController note = Note.find(params[:id]) uploader = note.attachment - if uploader.file_storage? - if can?(current_user, :read_project, note.project) - # Replace old notes location in /public with the new one in / and send the file + if can?(current_user, :read_project, note.project) + if uploader.file_storage? path = uploader.file.path.gsub("#{Rails.root}/public", Rails.root.to_s) - disposition = uploader.image? ? 'inline' : 'attachment' - send_file path, disposition: disposition + if File.exist?(path) + disposition = uploader.image? ? 'inline' : 'attachment' + send_file path, disposition: disposition + else + not_found! + end else - not_found! + redirect_to uploader.url end else - redirect_to uploader.url + not_found! end end end |