diff options
author | Nick Thomas <nick@gitlab.com> | 2019-04-11 15:33:27 +0100 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-04-16 15:16:23 +0100 |
commit | 4d52131dcf1a50142d4c1df557bd9e02b2cb2485 (patch) | |
tree | bcf08d99ea34e250dd8eb49bab1b98ca803d1718 /lib/gitlab/workhorse.rb | |
parent | 670b2c1af55ab5e993f3a3b05a1078e394f9ceda (diff) | |
download | gitlab-ce-4d52131dcf1a50142d4c1df557bd9e02b2cb2485.tar.gz |
Add a feature flag for subdirectory archives
Diffstat (limited to 'lib/gitlab/workhorse.rb')
-rw-r--r-- | lib/gitlab/workhorse.rb | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/lib/gitlab/workhorse.rb b/lib/gitlab/workhorse.rb index 2a8b1568f8b..46a7b5b982a 100644 --- a/lib/gitlab/workhorse.rb +++ b/lib/gitlab/workhorse.rb @@ -64,28 +64,33 @@ module Gitlab end def send_git_archive(repository, ref:, format:, append_sha:, path: nil) + path_enabled = Feature.enabled?(:git_archive_path, default_enabled: true) + path = nil unless path_enabled + format ||= 'tar.gz' format = format.downcase - metadata = repository.archive_metadata(ref, Gitlab.config.gitlab.repository_downloads_path, format, append_sha: append_sha, path: path) + + metadata = repository.archive_metadata( + ref, + Gitlab.config.gitlab.repository_downloads_path, + format, + append_sha: append_sha, + path: path + ) 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 = + if path_enabled + send_git_archive_params(repository, metadata, path, archive_format(format)) + else + metadata + end - # If present DisableCache must be a Boolean. Otherwise workhorse ignores it. + # If present, DisableCache must be a Boolean. Otherwise + # workhorse ignores it. params['DisableCache'] = true if git_archive_cache_disabled? + params['GitalyServer'] = gitaly_server_hash(repository) [ SEND_DATA_HEADER, @@ -273,6 +278,21 @@ module Gitlab Gitaly::GetArchiveRequest::Format::TAR_GZ end end + + def send_git_archive_params(repository, metadata, path, format) + { + 'ArchivePath' => metadata['ArchivePath'], + 'GetArchiveRequest' => encode_binary( + Gitaly::GetArchiveRequest.new( + repository: repository.gitaly_repository, + commit_id: metadata['CommitId'], + prefix: metadata['ArchivePrefix'], + format: format, + path: path.presence || "" + ).to_proto + ) + } + end end end end |