Skip to content
Snippets Groups Projects
Commit 24982017 authored by Valery Sizov's avatar Valery Sizov
Browse files

Merge branch 'lazily-load-blob-content' into 'master'

Lazily load LiteBlob#data

See merge request !25
parents bb927920 00a8ab61
No related branches found
No related tags found
1 merge request!25Lazily load LiteBlob#data
Pipeline #
Loading
Loading
@@ -7,18 +7,21 @@ module Elasticsearch
include Linguist::BlobHelper
include Elasticsearch::Git::EncoderHelper
 
attr_accessor :id, :name, :path, :data, :size, :mode, :commit_id
attr_accessor :id, :name, :path, :size, :mode, :commit_id
attr_writer :data
 
def initialize(repo, raw_blob_hash)
@id = raw_blob_hash[:oid]
blob = repo.lookup(@id)
@blob = repo.lookup(@id)
 
@mode = raw_blob_hash[:mode].to_s(8)
@size = blob.size
@size = @blob.size
@path = encode!(raw_blob_hash[:path])
@name = @path.split('/').last
@data = encode!(blob.content)
end
def data
@data ||= encode!(@blob.content)
end
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment