Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Kjellerstedt <pkj@axis.com>2012-06-21 08:26:56 (GMT)
committer Christian Johansen <christian@gitorious.com>2013-01-08 14:03:00 (GMT)
commit110edd6018d49211603934261736183b8e4b8b24 (patch)
treeaa130ba3023613b2f0d5e8becac58c43071e9c46
parent4175022f92b174240eb08807e288d01edec73cca (diff)
Allow max render and download size of blobs to be configured
-rw-r--r--app/controllers/blobs_controller.rb4
-rw-r--r--app/helpers/blobs_helper.rb2
-rw-r--r--config/gitorious.sample.yml6
3 files changed, 9 insertions, 3 deletions
diff --git a/app/controllers/blobs_controller.rb b/app/controllers/blobs_controller.rb
index 677bea7..d1ea70b 100644
--- a/app/controllers/blobs_controller.rb
+++ b/app/controllers/blobs_controller.rb
@@ -65,7 +65,7 @@ class BlobsController < ApplicationController
@ref, @path = branch_and_path(params[:branch_and_path], @git)
if @git.git.cat_file({:t => true}, @ref) == "blob"
@blob = @git.blob(@ref)
- if @blob.size > 500.kilobytes
+ if @blob.size > eval(GitoriousConfig["max_download_blob_size"] || '500.kilobytes')
flash[:error] = I18n.t "blobs_controller.raw_error", :size => @blob.size
redirect_to project_repository_path(@project, @repository) and return
end
@@ -80,7 +80,7 @@ class BlobsController < ApplicationController
if stale?(:etag => Digest::SHA1.hexdigest(@commit.id + params[:branch_and_path].join), :last_modified => @commit.committed_date.utc)
@blob = @git.tree(@commit.tree.id, ["#{@path.join("/")}"]).contents.first
render_not_found and return unless @blob
- if @blob.size > 500.kilobytes
+ if @blob.size > eval(GitoriousConfig["max_download_blob_size"] || '500.kilobytes')
flash[:error] = I18n.t "blobs_controller.raw_error", :size => @blob.size
redirect_to project_repository_path(@project, @repository) and return
end
diff --git a/app/helpers/blobs_helper.rb b/app/helpers/blobs_helper.rb
index 1649066..7335838 100644
--- a/app/helpers/blobs_helper.rb
+++ b/app/helpers/blobs_helper.rb
@@ -99,7 +99,7 @@ module BlobsHelper
end
def too_big_to_render?(size)
- size > 350.kilobytes
+ size > eval(GitoriousConfig["max_render_blob_size"] || '350.kilobytes')
end
class BlameRenderer
diff --git a/config/gitorious.sample.yml b/config/gitorious.sample.yml
index 312bc30..c70dbfe 100644
--- a/config/gitorious.sample.yml
+++ b/config/gitorious.sample.yml
@@ -222,6 +222,12 @@ production:
# Mangle visible e-mail addresses (spam protection)
#mangle_email_addresses: true
+ # The maximum size of a raw blob that can be downloaded.
+ #max_download_blob_size: 500.kilobytes
+
+ # The maximum size of a text blob that can be rendered.
+ #max_render_blob_size: 350.kilobytes
+
# Available project licenses. This can be configured as an array of licenses:
#
# licenses: