diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /app/models/pages/lookup_path.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/models/pages/lookup_path.rb')
-rw-r--r-- | app/models/pages/lookup_path.rb | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/app/models/pages/lookup_path.rb b/app/models/pages/lookup_path.rb index 84d820e539c..9855731778f 100644 --- a/app/models/pages/lookup_path.rb +++ b/app/models/pages/lookup_path.rb @@ -22,11 +22,7 @@ module Pages end def source - if artifacts_archive && !artifacts_archive.file_storage? - zip_source - else - file_source - end + zip_source || file_source end def prefix @@ -42,18 +38,36 @@ module Pages attr_reader :project, :trim_prefix, :domain def artifacts_archive - return unless Feature.enabled?(:pages_artifacts_archive, project) + return unless Feature.enabled?(:pages_serve_from_artifacts_archive, project) + + project.pages_metadatum.artifacts_archive + end + + def deployment + return unless Feature.enabled?(:pages_serve_from_deployments, project) - # Using build artifacts is temporary solution for quick test - # in production environment, we'll replace this with proper - # `pages_deployments` later - project.pages_metadatum.artifacts_archive&.file + project.pages_metadatum.pages_deployment end def zip_source + source = deployment || artifacts_archive + + return unless source&.file + + return if source.file.file_storage? && !Feature.enabled?(:pages_serve_with_zip_file_protocol, project) + + # artifacts archive doesn't support this + file_count = source.file_count if source.respond_to?(:file_count) + + global_id = ::Gitlab::GlobalId.build(source, id: source.id).to_s + { type: 'zip', - path: artifacts_archive.url(expire_at: 1.day.from_now) + path: source.file.url_or_file_path(expire_at: 1.day.from_now), + global_id: global_id, + sha256: source.file_sha256, + file_size: source.size, + file_count: file_count } end |