版本库 无法预览的文件提供直接下载功能

This commit is contained in:
huang 2016-03-09 11:30:28 +08:00
parent f469e51202
commit 99be187d54
1 changed files with 5 additions and 4 deletions

View File

@ -431,7 +431,10 @@ update
def entry
entry_and_raw(false)
render :layout => 'base_projects'
@content = @repository.cat(@path, @rev)
if is_entry_text_data?(@content, @path)
render :layout => 'base_projects'
end
end
def entry_and_raw(is_raw)
@ -443,9 +446,7 @@ update
@content = @repository.cat(@path, @rev)
(show_error_not_found; return) unless @content
if is_raw ||
(@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) ||
! is_entry_text_data?(@content, @path)
if is_raw || (@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) || !is_entry_text_data?(@content, @path)
# Force the download
send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) }
send_type = Redmine::MimeType.of(@path)