summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <zegerjan@gitlab.com>2016-04-14 12:44:35 +0200
committerZeger-Jan van de Weg <zegerjan@gitlab.com>2016-04-28 21:28:39 +0200
commitad99404d2588e182a115d89b0b457d957e8ca7b6 (patch)
tree527619b709363e1515c41c0d8f861995389a58d4 /app/models
parent3fd0f5374447f0763c60d5b10b35d4a6f6981497 (diff)
downloadgitlab-ce-ad99404d2588e182a115d89b0b457d957e8ca7b6.tar.gz
Properly handle bigger files
Diffstat (limited to 'app/models')
-rw-r--r--app/models/blob.rb8
-rw-r--r--app/models/snippet.rb4
2 files changed, 12 insertions, 0 deletions
diff --git a/app/models/blob.rb b/app/models/blob.rb
index 72e6c5fa3fd..0fea6b7f576 100644
--- a/app/models/blob.rb
+++ b/app/models/blob.rb
@@ -19,6 +19,14 @@ class Blob < SimpleDelegator
new(blob)
end
+ def no_highlighting?
+ size && size > 1.megabyte
+ end
+
+ def only_display_raw?
+ size && size > 5.megabytes
+ end
+
def svg?
text? && language && language.name == 'SVG'
end
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index b96e3937281..0fd08061925 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -112,6 +112,10 @@ class Snippet < ActiveRecord::Base
visibility_level
end
+ def no_highlighting?
+ content.lines.count > 1000
+ end
+
class << self
# Searches for snippets with a matching title or file name.
#