diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2015-12-31 09:25:59 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-01-14 12:48:14 +0100 |
commit | 447f56036e837fc9a9c2bcaf382d38dc513a9733 (patch) | |
tree | 160d315f5a787e3bf9a703e08793a98d7566ef1f | |
parent | e3ef0ac8f44118465cf5831982d2051d0986cda8 (diff) | |
download | gitlab-ce-447f56036e837fc9a9c2bcaf382d38dc513a9733.tar.gz |
Use metadata stored in artifacats metadata file
-rw-r--r-- | app/controllers/projects/artifacts_controller.rb | 4 | ||||
-rw-r--r-- | app/models/ci/build.rb | 19 | ||||
-rw-r--r-- | lib/gitlab/string_path.rb | 2 |
3 files changed, 20 insertions, 5 deletions
diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index 8a1ff383134..3a112587f72 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -18,8 +18,8 @@ class Projects::ArtifactsController < Projects::ApplicationController return render_404 unless build.artifacts? current_path = params[:path] ? "./#{params[:path]}/" : './' - artifacts_metadata = build.artifacts_metadata_for(current_path) - @path = Gitlab::StringPath.new(current_path, artifacts_metadata) + metadata = build.artifacts_metadata_for_path(current_path) + @path = Gitlab::StringPath.new(current_path, metadata) end private 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 diff --git a/lib/gitlab/string_path.rb b/lib/gitlab/string_path.rb index af80a502bf6..bfeb0f852f0 100644 --- a/lib/gitlab/string_path.rb +++ b/lib/gitlab/string_path.rb @@ -5,7 +5,7 @@ module Gitlab # This is IO-operations safe class, that does similar job to # Ruby's Pathname but without the risk of accessing filesystem. # - # TODO: better support for '../' and './' + # TODO, better support for '../' and './' # class StringPath attr_reader :path, :universe |