diff options
Diffstat (limited to 'app/models/blob_viewer/base.rb')
-rw-r--r-- | app/models/blob_viewer/base.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/app/models/blob_viewer/base.rb b/app/models/blob_viewer/base.rb index e6119d25fab..35965d01692 100644 --- a/app/models/blob_viewer/base.rb +++ b/app/models/blob_viewer/base.rb @@ -6,15 +6,15 @@ module BlobViewer self.loading_partial_name = 'loading' - delegate :partial_path, :loading_partial_path, :rich?, :simple?, :text?, :binary?, to: :class + delegate :partial_path, :loading_partial_path, :rich?, :simple?, :load_async?, :text?, :binary?, to: :class attr_reader :blob - attr_accessor :expanded delegate :project, to: :blob def initialize(blob) @blob = blob + @initially_binary = blob.binary? end def self.partial_path @@ -52,19 +52,15 @@ 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 - def load_async? - self.class.load_async? && render_error.nil? - end - def collapsed? return @collapsed if defined?(@collapsed) - @collapsed = !expanded && collapse_limit && blob.raw_size > collapse_limit + @collapsed = !blob.expanded? && collapse_limit && blob.raw_size > collapse_limit end def too_large? @@ -73,6 +69,10 @@ module BlobViewer @too_large = size_limit && blob.raw_size > size_limit end + def binary_detected_after_load? + !@initially_binary && blob.binary? + end + # This method is used on the server side to check whether we can attempt to # render the blob at all. Human-readable error messages are found in the # `BlobHelper#blob_render_error_reason` helper. |