diff options
| author | Robert Speicher <robert@gitlab.com> | 2016-01-21 23:23:02 +0000 |
|---|---|---|
| committer | Robert Speicher <robert@gitlab.com> | 2016-01-21 23:23:02 +0000 |
| commit | 3f5e6c6cf65640d01ac5c784b7ba47c74531519e (patch) | |
| tree | d7cd239ee6669386106773401fedaecfeed2092c /lib | |
| parent | 307b099064c598208ff25c8dbf5250d9561e62f3 (diff) | |
| parent | 9b0f57781e8c71eb0e627a63078fedcedfe62bbb (diff) | |
| download | gitlab-ce-3f5e6c6cf65640d01ac5c784b7ba47c74531519e.tar.gz | |
Merge branch 'ci/recursive-artifacts-entries' into 'master'
Add method to calculate total size of artifacts in subpath
See merge request !2500
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/gitlab/ci/build/artifacts/metadata.rb | 8 | ||||
| -rw-r--r-- | lib/gitlab/ci/build/artifacts/metadata/entry.rb | 7 |
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/gitlab/ci/build/artifacts/metadata.rb b/lib/gitlab/ci/build/artifacts/metadata.rb index 1344f5d120b..f2020c82d40 100644 --- a/lib/gitlab/ci/build/artifacts/metadata.rb +++ b/lib/gitlab/ci/build/artifacts/metadata.rb @@ -13,8 +13,8 @@ module Gitlab attr_reader :file, :path, :full_version - def initialize(file, path) - @file, @path = file, path + def initialize(file, path, **opts) + @file, @path, @opts = file, path, opts @full_version = read_version end @@ -52,7 +52,9 @@ module Gitlab def match_entries(gz) entries = {} - match_pattern = %r{^#{Regexp.escape(@path)}[^/]*/?$} + + child_pattern = '[^/]*/?$' unless @opts[:recursive] + match_pattern = /^#{Regexp.escape(@path)}#{child_pattern}/ until gz.eof? do begin diff --git a/lib/gitlab/ci/build/artifacts/metadata/entry.rb b/lib/gitlab/ci/build/artifacts/metadata/entry.rb index 25b71fc3275..7f4c750b6fd 100644 --- a/lib/gitlab/ci/build/artifacts/metadata/entry.rb +++ b/lib/gitlab/ci/build/artifacts/metadata/entry.rb @@ -95,6 +95,13 @@ module Gitlab children.empty? end + def total_size + descendant_pattern = %r{^#{Regexp.escape(@path)}} + entries.sum do |path, entry| + (entry[:size] if path =~ descendant_pattern).to_i + end + end + def to_s @path end |
