Show file size in artifacts browser using metadata
This commit is contained in:
parent
cd3b8bbd2f
commit
1b1793c253
6 changed files with 15 additions and 12 deletions
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue