diff options
author | Constance Okoghenun <constanceokoghenun@gmail.com> | 2019-04-11 19:27:52 +0200 |
---|---|---|
committer | Constance Okoghenun <constanceokoghenun@gmail.com> | 2019-04-11 19:27:52 +0200 |
commit | 17c58a18ab415a964faced32873394b60168523e (patch) | |
tree | ca2e1c25549d2d32aff9459ed7cfbf7016234058 /lib/gitlab/workhorse.rb | |
parent | bb5c5cb2307c0824de3ccf5cb45d2fda2688f23d (diff) | |
parent | dc8848794bfd2f06345d4dbba8a918aa09ee07a8 (diff) | |
download | gitlab-ce-17c58a18ab415a964faced32873394b60168523e.tar.gz |
Merge branch 'master' of https://gitlab.com/gitlab-org/gitlab-ce into 57318-track-discussion-thread-usage-on-gitlab-com-with-snowplow57318-track-discussion-thread-usage-on-gitlab-com-with-snowplow
Diffstat (limited to 'lib/gitlab/workhorse.rb')
-rw-r--r-- | lib/gitlab/workhorse.rb | 38 |
1 files changed, 4 insertions, 34 deletions
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 |