Commit 7d2affef authored by Phil Hughes's avatar Phil Hughes

moved lfs blob fetch from extractspath file

parent 3032989a
...@@ -26,7 +26,10 @@ class Projects::TreeController < Projects::ApplicationController ...@@ -26,7 +26,10 @@ class Projects::TreeController < Projects::ApplicationController
respond_to do |format| respond_to do |format|
format.html do format.html do
blob_ids = tree.blobs.map(&:id)
@last_commit = @repository.last_commit_for_path(@commit.id, @tree.path) || @commit @last_commit = @repository.last_commit_for_path(@commit.id, @tree.path) || @commit
@lfs_blob_ids = Gitlab::Git::Blob.batch_lfs_pointers(@repo, blob_ids).map(&:id)
end end
format.js do format.js do
......
...@@ -9,6 +9,7 @@ class ProjectsController < Projects::ApplicationController ...@@ -9,6 +9,7 @@ class ProjectsController < Projects::ApplicationController
before_action :repository, except: [:index, :new, :create] before_action :repository, except: [:index, :new, :create]
before_action :assign_ref_vars, only: [:show], if: :repo_exists? before_action :assign_ref_vars, only: [:show], if: :repo_exists?
before_action :tree, only: [:show], if: [:repo_exists?, :project_view_files?] before_action :tree, only: [:show], if: [:repo_exists?, :project_view_files?]
before_action :lfs_blob_ids, only: [:show], if: [:repo_exists?, :project_view_files?]
before_action :project_export_enabled, only: [:export, :download_export, :remove_export, :generate_new_export] before_action :project_export_enabled, only: [:export, :download_export, :remove_export, :generate_new_export]
# Authorize # Authorize
...@@ -403,4 +404,9 @@ class ProjectsController < Projects::ApplicationController ...@@ -403,4 +404,9 @@ class ProjectsController < Projects::ApplicationController
# #
redirect_to request.original_url.sub(/\.git\/?\Z/, '') if params[:format] == 'git' redirect_to request.original_url.sub(/\.git\/?\Z/, '') if params[:format] == 'git'
end end
def lfs_blob_ids
blob_ids = tree.blobs.map(&:id)
@lfs_blob_ids = Gitlab::Git::Blob.batch_lfs_pointers(@repo, blob_ids).map(&:id)
end
end end
...@@ -9,5 +9,5 @@ ...@@ -9,5 +9,5 @@
%small %small
= number_to_human_size(blob.raw_size) = number_to_human_size(blob.raw_size)
- if blob.stored_externally? - if blob.stored_externally? && blob.external_storage == :lfs
%span.label.label-lfs.append-right-5 LFS %span.label.label-lfs.append-right-5 LFS
- is_lfs_blob = @lfs_blobs.select{|b| b.id === blob_item.id }.any? - is_lfs_blob = @lfs_blob_ids.include?(blob_item.id)
%tr{ class: "tree-item #{tree_hex_class(blob_item)}" } %tr{ class: "tree-item #{tree_hex_class(blob_item)}" }
%td.tree-item-file-name %td.tree-item-file-name
= tree_icon(type, blob_item.mode, blob_item.name) = tree_icon(type, blob_item.mode, blob_item.name)
......
...@@ -127,10 +127,6 @@ module ExtractsPath ...@@ -127,10 +127,6 @@ module ExtractsPath
@hex_path = Digest::SHA1.hexdigest(@path) @hex_path = Digest::SHA1.hexdigest(@path)
@logs_path = logs_file_project_ref_path(@project, @ref, @path) @logs_path = logs_file_project_ref_path(@project, @ref, @path)
blob_ids = tree.blobs.map(&:id)
@lfs_blobs = Gitlab::Git::Blob.batch_lfs_pointers(@repo, blob_ids)
rescue RuntimeError, NoMethodError, InvalidPathError rescue RuntimeError, NoMethodError, InvalidPathError
render_404 render_404
end end
......
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