summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-12-14 10:10:20 +0000
committerPhil Hughes <me@iamphill.com>2017-12-14 10:10:20 +0000
commit7d2affeff1885fb9984fed1088c8dffdc41a7320 (patch)
treeb572cd9484abad0cfadee819a52a7db49ce8def2
parent3032989ad4e8b93e5ad60cdbb817d1be5f9edacb (diff)
downloadgitlab-ce-7d2affeff1885fb9984fed1088c8dffdc41a7320.tar.gz
moved lfs blob fetch from extractspath file
-rw-r--r--app/controllers/projects/tree_controller.rb3
-rw-r--r--app/controllers/projects_controller.rb6
-rw-r--r--app/views/projects/blob/_header_content.html.haml2
-rw-r--r--app/views/projects/tree/_blob_item.html.haml2
-rw-r--r--lib/extracts_path.rb4
5 files changed, 11 insertions, 6 deletions
diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb
index f3719059f88..2998ec21dca 100644
--- a/app/controllers/projects/tree_controller.rb
+++ b/app/controllers/projects/tree_controller.rb
@@ -26,7 +26,10 @@ class Projects::TreeController < Projects::ApplicationController
respond_to do |format|
format.html do
+ blob_ids = tree.blobs.map(&:id)
+
@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
format.js do
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 3882fa4791d..bce3a8d42e4 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -9,6 +9,7 @@ class ProjectsController < Projects::ApplicationController
before_action :repository, except: [:index, :new, :create]
before_action :assign_ref_vars, only: [:show], if: :repo_exists?
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]
# Authorize
@@ -403,4 +404,9 @@ class ProjectsController < Projects::ApplicationController
#
redirect_to request.original_url.sub(/\.git\/?\Z/, '') if params[:format] == 'git'
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
diff --git a/app/views/projects/blob/_header_content.html.haml b/app/views/projects/blob/_header_content.html.haml
index cf7619eb547..5d457a50c49 100644
--- a/app/views/projects/blob/_header_content.html.haml
+++ b/app/views/projects/blob/_header_content.html.haml
@@ -9,5 +9,5 @@
%small
= 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
diff --git a/app/views/projects/tree/_blob_item.html.haml b/app/views/projects/tree/_blob_item.html.haml
index d1ab49920eb..8c1c532cb3e 100644
--- a/app/views/projects/tree/_blob_item.html.haml
+++ b/app/views/projects/tree/_blob_item.html.haml
@@ -1,4 +1,4 @@
-- 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)}" }
%td.tree-item-file-name
= tree_icon(type, blob_item.mode, blob_item.name)
diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb
index bab46281922..f576ef74603 100644
--- a/lib/extracts_path.rb
+++ b/lib/extracts_path.rb
@@ -127,10 +127,6 @@ module ExtractsPath
@hex_path = Digest::SHA1.hexdigest(@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
render_404
end