lib/gitlab_git/blob.rb in gitlab_git-10.2.0 vs lib/gitlab_git/blob.rb in gitlab_git-10.2.1

- old
+ new

@@ -11,11 +11,11 @@ # the user. We load as much as we can for encoding detection # (Linguist) and LFS pointer parsing. All other cases where we need full # blob data should use load_all_data!. MAX_DATA_DISPLAY_SIZE = 10485760 - attr_accessor :name, :path, :size, :data, :mode, :id, :commit_id + attr_accessor :name, :path, :size, :data, :mode, :id, :commit_id, :loaded_size class << self def find(repository, sha, path) commit = repository.lookup(sha) root_tree = commit.tree @@ -213,10 +213,12 @@ %w(id name path size data mode commit_id).each do |key| self.send("#{key}=", options[key.to_sym]) end @loaded_all_data = false + # Retain the actual size before it is encoded + @loaded_size = @data.bytesize end def empty? !data || data == '' end @@ -231,10 +233,11 @@ return if @data == '' # don't mess with submodule blobs return @data if @loaded_all_data @loaded_all_data = true @data = repository.lookup(id).content + @loaded_size = @data.bytesize end def name encode! @name end @@ -265,10 +268,10 @@ nil end def truncated? - size > data.bytes.size + size && (size > loaded_size) end private def has_lfs_version_key?