summaryrefslogtreecommitdiff
path: root/app/controllers/files_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/files_controller.rb')
-rw-r--r--app/controllers/files_controller.rb17
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