Commit 1b1793c2 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Show file size in artifacts browser using metadata

parent cd3b8bbd
...@@ -4,3 +4,4 @@ ...@@ -4,3 +4,4 @@
%span.str-truncated %span.str-truncated
= link_to directory.name, browse_namespace_project_build_artifacts_path(@project.namespace, @project, @build, path: directory.path) = link_to directory.name, browse_namespace_project_build_artifacts_path(@project.namespace, @project, @build, path: directory.path)
%td %td
%td
%tr{ class: 'tree-item' } %tr{ class: 'tree-item' }
%td.tree-item-file-name %td.tree-item-file-name
= tree_icon('file', '664', file.basename) = tree_icon('file', '664', file.name)
%span.str-truncated %span.str-truncated
= file.basename = file.name
%td
= number_to_human_size(file.metadata[:uncompressed_size], precision: 2)
%td %td
= link_to '', class: 'btn btn-xs btn-default' do = link_to '', class: 'btn btn-xs btn-default' do
= icon('download') = icon('download')
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
%thead %thead
%tr %tr
%th Name %th Name
%th Size
%th Download %th Download
= render partial: 'tree_directory', collection: @path.directories!, as: :directory = render partial: 'tree_directory', collection: @path.directories!, as: :directory
= render partial: 'tree_file', collection: @path.files, as: :file = render partial: 'tree_file', collection: @path.files, as: :file
......
...@@ -23,13 +23,12 @@ module Gitlab ...@@ -23,13 +23,12 @@ module Gitlab
each do |line| each do |line|
next unless line =~ %r{^#{Regexp.escape(@path)}[^/\s]*/?\s} next unless line =~ %r{^#{Regexp.escape(@path)}[^/\s]*/?\s}
path, meta = line.split(' ') path, meta = line.split(' ')
paths.push(path) paths.push(path)
metadata.push(meta) metadata.push(meta)
end end
[paths, metadata.map { |meta| JSON.parse(meta) }] [paths, metadata.map { |meta| JSON.parse(meta, symbolize_names: true) }]
end end
def to_string_path def to_string_path
......
...@@ -19,10 +19,6 @@ module Gitlab ...@@ -19,10 +19,6 @@ module Gitlab
@path @path
end end
def exists?
@path == './' || @universe.include?(@path)
end
def absolute? def absolute?
@path.start_with?('/') @path.start_with?('/')
end end
...@@ -94,13 +90,17 @@ module Gitlab ...@@ -94,13 +90,17 @@ module Gitlab
def metadata def metadata
index = @universe.index(@path) index = @universe.index(@path)
@metadata[index] @metadata[index] || {}
end end
def nodes def nodes
@path.count('/') + (file? ? 1 : 0) @path.count('/') + (file? ? 1 : 0)
end end
def exists?
@path == './' || @universe.include?(@path)
end
def ==(other) def ==(other)
@path == other.path && @universe == other.universe @path == other.path && @universe == other.universe
end end
...@@ -112,7 +112,7 @@ module Gitlab ...@@ -112,7 +112,7 @@ module Gitlab
private private
def new(path) def new(path)
self.class.new(path, @universe) self.class.new(path, @universe, @metadata)
end end
def select def select
......
...@@ -162,7 +162,7 @@ describe Gitlab::StringPath do ...@@ -162,7 +162,7 @@ describe Gitlab::StringPath do
end end
let(:metadata) do let(:metadata) do
[{ name: '/path/'}, { name: '/path/file1' }, { name: '/path/file2' }] [{ name: '/path/' }, { name: '/path/file1' }, { name: '/path/file2' }]
end end
subject do subject 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