Commit 64c8ee47 authored by Jacob Vosmaer's avatar Jacob Vosmaer

WIP lazy blobs

parent 481644ca
...@@ -33,6 +33,7 @@ class Projects::BlobController < Projects::ApplicationController ...@@ -33,6 +33,7 @@ class Projects::BlobController < Projects::ApplicationController
def edit def edit
@last_commit = Gitlab::Git::Commit.last_for_path(@repository, @ref, @path).sha @last_commit = Gitlab::Git::Commit.last_for_path(@repository, @ref, @path).sha
blob.load_all_data!(@repository)
end end
def update def update
...@@ -51,6 +52,7 @@ class Projects::BlobController < Projects::ApplicationController ...@@ -51,6 +52,7 @@ class Projects::BlobController < Projects::ApplicationController
def preview def preview
@content = params[:content] @content = params[:content]
@blob.load_all_data!(@repository)
diffy = Diffy::Diff.new(@blob.data, @content, diff: '-U 3', include_diff_info: true) diffy = Diffy::Diff.new(@blob.data, @content, diff: '-U 3', include_diff_info: true)
@diff_lines = Gitlab::Diff::Parser.new.parse(diffy.diff.scan(/.*\n/)) @diff_lines = Gitlab::Diff::Parser.new.parse(diffy.diff.scan(/.*\n/))
...@@ -65,6 +67,7 @@ class Projects::BlobController < Projects::ApplicationController ...@@ -65,6 +67,7 @@ class Projects::BlobController < Projects::ApplicationController
end end
def diff def diff
@blob.load_all_data!(@repository)
@form = UnfoldForm.new(params) @form = UnfoldForm.new(params)
@lines = @blob.data.lines[@form.since - 1..@form.to - 1] @lines = @blob.data.lines[@form.since - 1..@form.to - 1]
......
...@@ -205,7 +205,11 @@ module Ci ...@@ -205,7 +205,11 @@ module Ci
end end
def ci_yaml_file def ci_yaml_file
@ci_yaml_file ||= project.repository.blob_at(sha, '.gitlab-ci.yml').data return @ci_yaml_file if defined?(@ci_yaml_file)
blob = project.repository.blob_at(sha, '.gitlab-ci.yml')
blob.load_all_data!(project.repository)
@ci_yaml_file = blob.data
rescue rescue
nil nil
end end
......
...@@ -31,6 +31,8 @@ class Tree ...@@ -31,6 +31,8 @@ class Tree
git_repo = repository.raw_repository git_repo = repository.raw_repository
@readme = Gitlab::Git::Blob.find(git_repo, sha, readme_path) @readme = Gitlab::Git::Blob.find(git_repo, sha, readme_path)
@readme.load_all_data!(git_repo)
@readme
end end
def trees def trees
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
- if blob.lfs_pointer? - if blob.lfs_pointer?
= render "download", blob: blob = render "download", blob: blob
- elsif blob.text? - elsif blob.text?
- blob.load_all_data!(@repository)
= render "text", blob: blob = render "text", blob: blob
- elsif blob.image? - elsif blob.image?
= render "image", blob: blob = render "image", blob: blob
......
...@@ -58,9 +58,11 @@ module API ...@@ -58,9 +58,11 @@ module API
commit = user_project.commit(ref) commit = user_project.commit(ref)
not_found! 'Commit' unless commit not_found! 'Commit' unless commit
blob = user_project.repository.blob_at(commit.sha, file_path) repo = user_project.repository
blob = repo.blob_at(commit.sha, file_path)
if blob if blob
blob.load_all_data!(repo)
status(200) status(200)
{ {
...@@ -72,7 +74,7 @@ module API ...@@ -72,7 +74,7 @@ module API
ref: ref, ref: ref,
blob_id: blob.id, blob_id: blob.id,
commit_id: commit.id, commit_id: commit.id,
last_commit_id: user_project.repository.last_commit_for_path(commit.sha, file_path).id last_commit_id: repo.last_commit_for_path(commit.sha, file_path).id
} }
else else
not_found! 'File' not_found! 'File'
......
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