Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2019-04-11 17:33:27 +0300
committerNick Thomas <nick@gitlab.com>2019-04-16 17:16:23 +0300
commit4d52131dcf1a50142d4c1df557bd9e02b2cb2485 (patch)
treebcf08d99ea34e250dd8eb49bab1b98ca803d1718 /lib
parent670b2c1af55ab5e993f3a3b05a1078e394f9ceda (diff)
Add a feature flag for subdirectory archives
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/workhorse.rb50
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