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

Show file size in artifacts browser using metadata

parent cd3b8bbd
......@@ -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
%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')
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
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