Commit 447f5603 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Use metadata stored in artifacats metadata file

parent e3ef0ac8
...@@ -18,8 +18,8 @@ class Projects::ArtifactsController < Projects::ApplicationController ...@@ -18,8 +18,8 @@ class Projects::ArtifactsController < Projects::ApplicationController
return render_404 unless build.artifacts? return render_404 unless build.artifacts?
current_path = params[:path] ? "./#{params[:path]}/" : './' current_path = params[:path] ? "./#{params[:path]}/" : './'
artifacts_metadata = build.artifacts_metadata_for(current_path) metadata = build.artifacts_metadata_for_path(current_path)
@path = Gitlab::StringPath.new(current_path, artifacts_metadata) @path = Gitlab::StringPath.new(current_path, metadata)
end end
private private
......
...@@ -349,8 +349,23 @@ module Ci ...@@ -349,8 +349,23 @@ module Ci
artifacts? && artifacts_file.path.end_with?('zip') && artifacts_metadata.exists? artifacts? && artifacts_file.path.end_with?('zip') && artifacts_metadata.exists?
end 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 end
private private
......
...@@ -5,7 +5,7 @@ module Gitlab ...@@ -5,7 +5,7 @@ module Gitlab
# This is IO-operations safe class, that does similar job to # This is IO-operations safe class, that does similar job to
# Ruby's Pathname but without the risk of accessing filesystem. # Ruby's Pathname but without the risk of accessing filesystem.
# #
# TODO: better support for '../' and './' # TODO, better support for '../' and './'
# #
class StringPath class StringPath
attr_reader :path, :universe attr_reader :path, :universe
......
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