summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/views/projects/artifacts/_tree_directory.html.haml1
-rw-r--r--app/views/projects/artifacts/_tree_file.html.haml6
-rw-r--r--app/views/projects/artifacts/browse.html.haml1
-rw-r--r--lib/gitlab/ci/build/artifacts/metadata.rb5
-rw-r--r--lib/gitlab/string_path.rb12
-rw-r--r--spec/lib/gitlab/string_path_spec.rb2
6 files changed, 15 insertions, 12 deletions
diff --git a/app/views/projects/artifacts/_tree_directory.html.haml b/app/views/projects/artifacts/_tree_directory.html.haml
index 481a2cb072f..5b87d55efd5 100644
--- a/app/views/projects/artifacts/_tree_directory.html.haml
+++ b/app/views/projects/artifacts/_tree_directory.html.haml
@@ -4,3 +4,4 @@
%span.str-truncated
= link_to directory.name, browse_namespace_project_build_artifacts_path(@project.namespace, @project, @build, path: directory.path)
%td
+ %td
diff --git a/app/views/projects/artifacts/_tree_file.html.haml b/app/views/projects/artifacts/_tree_file.html.haml
index ff30acc2957..0059f845841 100644
--- a/app/views/projects/artifacts/_tree_file.html.haml
+++ b/app/views/projects/artifacts/_tree_file.html.haml
@@ -1,8 +1,10 @@
%tr{ class: 'tree-item' }
%td.tree-item-file-name
- = tree_icon('file', '664', file.basename)
+ = tree_icon('file', '664', file.name)
%span.str-truncated
- = file.basename
+ = file.name
+ %td
+ = number_to_human_size(file.metadata[:uncompressed_size], precision: 2)
%td
= link_to '', class: 'btn btn-xs btn-default' do
= icon('download')
diff --git a/app/views/projects/artifacts/browse.html.haml b/app/views/projects/artifacts/browse.html.haml
index f05e5d58265..fc161be2ffc 100644
--- a/app/views/projects/artifacts/browse.html.haml
+++ b/app/views/projects/artifacts/browse.html.haml
@@ -15,6 +15,7 @@
%thead
%tr
%th Name
+ %th Size
%th Download
= render partial: 'tree_directory', collection: @path.directories!, as: :directory
= render partial: 'tree_file', collection: @path.files, as: :file
diff --git a/lib/gitlab/ci/build/artifacts/metadata.rb b/lib/gitlab/ci/build/artifacts/metadata.rb
index d5c3cd10e48..1f3000e7c8a 100644
--- a/lib/gitlab/ci/build/artifacts/metadata.rb
+++ b/lib/gitlab/ci/build/artifacts/metadata.rb
@@ -23,13 +23,12 @@ module Gitlab
each do |line|
next unless line =~ %r{^#{Regexp.escape(@path)}[^/\s]*/?\s}
-
path, meta = line.split(' ')
paths.push(path)
metadata.push(meta)
- end
+ end
- [paths, metadata.map { |meta| JSON.parse(meta) }]
+ [paths, metadata.map { |meta| JSON.parse(meta, symbolize_names: true) }]
end
def to_string_path
diff --git a/lib/gitlab/string_path.rb b/lib/gitlab/string_path.rb
index a6234d34e7d..774d4244a2a 100644
--- a/lib/gitlab/string_path.rb
+++ b/lib/gitlab/string_path.rb
@@ -19,10 +19,6 @@ module Gitlab
@path
end
- def exists?
- @path == './' || @universe.include?(@path)
- end
-
def absolute?
@path.start_with?('/')
end
@@ -94,13 +90,17 @@ module Gitlab
def metadata
index = @universe.index(@path)
- @metadata[index]
+ @metadata[index] || {}
end
def nodes
@path.count('/') + (file? ? 1 : 0)
end
+ def exists?
+ @path == './' || @universe.include?(@path)
+ end
+
def ==(other)
@path == other.path && @universe == other.universe
end
@@ -112,7 +112,7 @@ module Gitlab
private
def new(path)
- self.class.new(path, @universe)
+ self.class.new(path, @universe, @metadata)
end
def select
diff --git a/spec/lib/gitlab/string_path_spec.rb b/spec/lib/gitlab/string_path_spec.rb
index 861eb951236..7f1d111478b 100644
--- a/spec/lib/gitlab/string_path_spec.rb
+++ b/spec/lib/gitlab/string_path_spec.rb
@@ -162,7 +162,7 @@ describe Gitlab::StringPath do
end
let(:metadata) do
- [{ name: '/path/'}, { name: '/path/file1' }, { name: '/path/file2' }]
+ [{ name: '/path/' }, { name: '/path/file1' }, { name: '/path/file2' }]
end
subject do