diff options
author | Patrick Bajao <ebajao@gitlab.com> | 2019-04-11 15:49:53 -0800 |
---|---|---|
committer | Patrick Bajao <ebajao@gitlab.com> | 2019-04-11 15:49:53 +0800 |
commit | 171818df0a72097aa1a804c8213666b3f66b0966 (patch) | |
tree | ba412628c7f5a23fe31622f0e22af01bc9288855 /lib | |
parent | a4262919f76d7d2f82754753dc03b6d2bf310905 (diff) | |
download | gitlab-ce-171818df0a72097aa1a804c8213666b3f66b0966.tar.gz |
Revert "Merge branch '24704-download-repository-path' into 'master'"revert-24704-download-repository-path
This reverts commit 6c75bd015cba181f028bc87c396c3d8e43b5dc3e, reversing
changes made to 1be7f5aaa38aba79843eae8835be6c99c025e982.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/git/repository.rb | 7 | ||||
-rw-r--r-- | lib/gitlab/workhorse.rb | 38 |
2 files changed, 7 insertions, 38 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index c33d243330d..7d6851a4b8d 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -231,12 +231,12 @@ module Gitlab end end - def archive_metadata(ref, storage_path, project_path, format = "tar.gz", append_sha:, path: nil) + def archive_metadata(ref, storage_path, project_path, format = "tar.gz", append_sha:) ref ||= root_ref commit = Gitlab::Git::Commit.find(self, ref) return {} if commit.nil? - prefix = archive_prefix(ref, commit.id, project_path, append_sha: append_sha, path: path) + prefix = archive_prefix(ref, commit.id, project_path, append_sha: append_sha) { 'ArchivePrefix' => prefix, @@ -248,14 +248,13 @@ module Gitlab # This is both the filename of the archive (missing the extension) and the # name of the top-level member of the archive under which all files go - def archive_prefix(ref, sha, project_path, append_sha:, path:) + def archive_prefix(ref, sha, project_path, append_sha:) append_sha = (ref != sha) if append_sha.nil? formatted_ref = ref.tr('/', '-') prefix_segments = [project_path, formatted_ref] prefix_segments << sha if append_sha - prefix_segments << path.tr('/', '-').gsub(%r{^/|/$}, '') if path prefix_segments.join('-') end diff --git a/lib/gitlab/workhorse.rb b/lib/gitlab/workhorse.rb index 533757d2237..0c2acac3d1e 100644 --- a/lib/gitlab/workhorse.rb +++ b/lib/gitlab/workhorse.rb @@ -63,26 +63,13 @@ module Gitlab ] end - def send_git_archive(repository, ref:, format:, append_sha:, path: nil) + def send_git_archive(repository, ref:, format:, append_sha:) format ||= 'tar.gz' format = format.downcase - metadata = repository.archive_metadata(ref, Gitlab.config.gitlab.repository_downloads_path, format, append_sha: append_sha, path: path) + params = repository.archive_metadata(ref, Gitlab.config.gitlab.repository_downloads_path, format, append_sha: append_sha) + raise "Repository or ref not found" if params.empty? - raise "Repository or ref not found" if metadata.empty? - - params = { - 'GitalyServer' => gitaly_server_hash(repository), - 'ArchivePath' => metadata['ArchivePath'], - 'GetArchiveRequest' => encode_binary( - Gitaly::GetArchiveRequest.new( - repository: repository.gitaly_repository, - commit_id: metadata['CommitId'], - prefix: metadata['ArchivePrefix'], - format: archive_format(format), - path: path.presence || "" - ).to_proto - ) - } + params['GitalyServer'] = gitaly_server_hash(repository) # If present DisableCache must be a Boolean. Otherwise workhorse ignores it. params['DisableCache'] = true if git_archive_cache_disabled? @@ -233,10 +220,6 @@ module Gitlab Base64.urlsafe_encode64(JSON.dump(hash)) end - def encode_binary(binary) - Base64.urlsafe_encode64(binary) - end - def gitaly_server_hash(repository) { address: Gitlab::GitalyClient.address(repository.project.repository_storage), @@ -255,19 +238,6 @@ module Gitlab def git_archive_cache_disabled? ENV['WORKHORSE_ARCHIVE_CACHE_DISABLED'].present? || Feature.enabled?(:workhorse_archive_cache_disabled) end - - def archive_format(format) - case format - when "tar.bz2", "tbz", "tbz2", "tb2", "bz2" - Gitaly::GetArchiveRequest::Format::TAR_BZ2 - when "tar" - Gitaly::GetArchiveRequest::Format::TAR - when "zip" - Gitaly::GetArchiveRequest::Format::ZIP - else - Gitaly::GetArchiveRequest::Format::TAR_GZ - end - end end end end |