diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-06-07 00:26:31 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-06-08 18:07:17 +0300 |
commit | 369d681eec8177f03bf3b4f694e03098447dae09 (patch) | |
tree | 53b45d655a1598624a743b3348571843538e1caf /app/models | |
parent | 1bc80c2587323b9107ec3fb2fe6024d7e7817e35 (diff) |
Add Blob#file_type convenience method
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/blob.rb | 4 | ||||
-rw-r--r-- | app/models/blob_viewer/base.rb | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/app/models/blob.rb b/app/models/blob.rb index fd95a1b299b..a7c1a6f51a9 100644 --- a/app/models/blob.rb +++ b/app/models/blob.rb @@ -155,6 +155,10 @@ class Blob < SimpleDelegator @extension ||= extname.downcase.delete('.') end + def file_type + Gitlab::FileDetector.type_of(path) + end + def video? UploaderHelper::VIDEO_EXT.include?(extension) end diff --git a/app/models/blob_viewer/base.rb b/app/models/blob_viewer/base.rb index e6119d25fab..d2aa33d994e 100644 --- a/app/models/blob_viewer/base.rb +++ b/app/models/blob_viewer/base.rb @@ -52,7 +52,7 @@ module BlobViewer def self.can_render?(blob, verify_binary: true) return false if verify_binary && binary? != blob.binary? return true if extensions&.include?(blob.extension) - return true if file_types&.include?(Gitlab::FileDetector.type_of(blob.path)) + return true if file_types&.include?(blob.file_type) false end |