From b0414ec1fbabfa8fa84e69eedcf7617fb969fd82 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Sat, 5 May 2012 01:01:29 +0000 Subject: route: scm: split entry and raw actions git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9625 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/repositories_controller.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 1fb708355..d74b59b60 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -152,7 +152,15 @@ class RepositoriesController < ApplicationController end end + def raw + entry_and_raw(true) + end + def entry + entry_and_raw(false) + end + + def entry_and_raw(is_raw) @entry = @repository.entry(@path, @rev) (show_error_not_found; return) unless @entry @@ -161,7 +169,7 @@ class RepositoriesController < ApplicationController @content = @repository.cat(@path, @rev) (show_error_not_found; return) unless @content - if 'raw' == params[:format] || + if is_raw || (@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) || ! is_entry_text_data?(@content, @path) # Force the download @@ -177,6 +185,7 @@ class RepositoriesController < ApplicationController @changeset = @repository.find_changeset_by_name(@rev) end end + private :entry_and_raw def is_entry_text_data?(ent, path) # UTF-16 contains "\x00". -- cgit v1.2.3