summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-01-04 13:08:49 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-01-14 12:48:15 +0100
commita7f99b67a0bf1160f41ebf4dc92c618eb13a7a10 (patch)
treefaba38ae6a6fcadb57fe564891912d37bed462ba /app
parentdf41148662142ce20a77b092665f48dd4dfa7bfb (diff)
downloadgitlab-ce-a7f99b67a0bf1160f41ebf4dc92c618eb13a7a10.tar.gz
Extract artifacts metadata implementation to separate class
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects/artifacts_controller.rb5
-rw-r--r--app/models/ci/build.rb20
2 files changed, 4 insertions, 21 deletions
diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb
index 5bd0c8cd780..ee1b1f375dc 100644
--- a/app/controllers/projects/artifacts_controller.rb
+++ b/app/controllers/projects/artifacts_controller.rb
@@ -16,10 +16,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
def browse
return render_404 unless build.artifacts?
-
- current_path = params[:path] ? "./#{params[:path]}/" : './'
- paths, metadata = build.artifacts_metadata_for_path(current_path)
- @path = Gitlab::StringPath.new(current_path, paths, metadata)
+ @path = build.artifacts_metadata_string_path(params[:path] || './')
end
private
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index df51a5ce079..7983ce0e88e 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -349,24 +349,10 @@ module Ci
artifacts? && artifacts_file.path.end_with?('zip') && artifacts_metadata.exists?
end
- def artifacts_metadata_for_path(path)
- return [] unless artifacts_metadata.exists?
- paths, metadata = [], []
-
- metadata_path = path.sub(/^\.\//, '')
- File.open(artifacts_metadata.path) do |file|
- gzip = Zlib::GzipReader.new(file)
- gzip.each_line do |line|
- if line =~ %r{^#{Regexp.escape(metadata_path)}[^/\s]+/?\s}
- matched_path, matched_meta = line.split(' ')
- paths << matched_path
- metadata << JSON.parse(matched_meta)
- end
- end
- gzip.close
- end
- [paths, metadata]
+ def artifacts_metadata_string_path(path)
+ file = artifacts_metadata.path
+ Gitlab::Ci::Build::Artifacts::Metadata.new(file, path).to_string_path
end
private