Commit e7c494cc authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'fix-lazy-blobs-requesting-all-previous-blobs' into 'master'

Ensure that we only request blobs in one batch

Closes #60829

See merge request gitlab-org/gitlab-ce!27625
parents 6b90db7d 1885691b
---
title: Fix Blob.lazy always loading all previously-requested blobs when a new request
is made
merge_request:
author:
type: performance
...@@ -55,13 +55,13 @@ module Gitlab ...@@ -55,13 +55,13 @@ module Gitlab
def get_blobs(revision_paths, limit = -1) def get_blobs(revision_paths, limit = -1)
return [] if revision_paths.empty? return [] if revision_paths.empty?
revision_paths.map! do |rev, path| request_revision_paths = revision_paths.map do |rev, path|
Gitaly::GetBlobsRequest::RevisionPath.new(revision: rev, path: encode_binary(path)) Gitaly::GetBlobsRequest::RevisionPath.new(revision: rev, path: encode_binary(path))
end end
request = Gitaly::GetBlobsRequest.new( request = Gitaly::GetBlobsRequest.new(
repository: @gitaly_repo, repository: @gitaly_repo,
revision_paths: revision_paths, revision_paths: request_revision_paths,
limit: limit limit: limit
) )
......
...@@ -43,6 +43,21 @@ describe Blob do ...@@ -43,6 +43,21 @@ describe Blob do
changelog.id changelog.id
contributing.id contributing.id
end end
it 'does not include blobs from previous requests in later requests' do
changelog = described_class.lazy(project, commit_id, 'CHANGELOG')
contributing = described_class.lazy(same_project, commit_id, 'CONTRIBUTING.md')
# Access property so the values are loaded
changelog.id
contributing.id
readme = described_class.lazy(project, commit_id, 'README.md')
expect(project.repository).to receive(:blobs_at).with([[commit_id, 'README.md']]).once.and_call_original
readme.id
end
end end
describe '#data' do describe '#data' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment