diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-02-20 15:37:37 +0100 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-02-20 15:37:37 +0100 |
commit | 218283b368161130f43333e75629870c9649b319 (patch) | |
tree | c266f2c98aa3b199569a482fc0a651c484dd486f /app/controllers/uploads_controller.rb | |
parent | 4ef6ffaad3e9b7a29b438722e5e101de78521ec7 (diff) | |
parent | 65b125a5035cb021aeb81e168fd4ae1ad6c74c11 (diff) | |
download | gitlab-ce-218283b368161130f43333e75629870c9649b319.tar.gz |
Merge branch 'extend_markdown_upload' into generic-uploads
# Conflicts:
# app/controllers/files_controller.rb
# app/controllers/projects/uploads_controller.rb
# app/uploaders/attachment_uploader.rb
Diffstat (limited to 'app/controllers/uploads_controller.rb')
-rw-r--r-- | app/controllers/uploads_controller.rb | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index d5877977258..508c2a6221a 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -3,15 +3,13 @@ class UploadsController < ApplicationController model = params[:model].camelize.constantize.find(params[:id]) uploader = model.send(params[:mounted_as]) - if uploader.file_storage? - if !model.respond_to?(:project) || can?(current_user, :read_project, model.project) - disposition = uploader.image? ? 'inline' : 'attachment' - send_file uploader.file.path, disposition: disposition - else - not_found! - end - else - redirect_to uploader.url - end + return not_found! if model.respond_to?(:project) && !can?(current_user, :read_project, model.project) + + return redirect_to uploader.url unless uploader.file_storage? + + return not_found! unless uploader.file.exists? + + disposition = uploader.image? ? 'inline' : 'attachment' + send_file uploader.file.path, disposition: disposition end end |