diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2015-12-31 11:25:59 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-01-14 14:48:14 +0300 |
commit | 447f56036e837fc9a9c2bcaf382d38dc513a9733 (patch) | |
tree | 160d315f5a787e3bf9a703e08793a98d7566ef1f /app/models/ci | |
parent | e3ef0ac8f44118465cf5831982d2051d0986cda8 (diff) |
Use metadata stored in artifacats metadata file
Diffstat (limited to 'app/models/ci')
-rw-r--r-- | app/models/ci/build.rb | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 98f9e6911f2..2c389bbdf61 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -349,8 +349,23 @@ module Ci artifacts? && artifacts_file.path.end_with?('zip') && artifacts_metadata.exists? end - def artifacts_metadata_for(path) - {} + def artifacts_metadata_for_path(path) + return {} unless artifacts_metadata.exists? + metadata = [] + meta_path = path.sub(/^\.\//, '') + + File.open(artifacts_metadata.path) do |file| + gzip = Zlib::GzipReader.new(file) + gzip.each_line do |line| + if line =~ %r{^#{meta_path}[^/]+/?\s} + path, meta = line.split(' ') + metadata << path + end + end + gzip.close + end + + metadata end private |