diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-21 03:09:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-21 03:09:36 +0300 |
commit | 707bf4370dc9ce78be253e7569eeb03a9b6e48d1 (patch) | |
tree | ca77942bb16e8a7f1aa38a84d853b4c517a33c56 /app/models/pages | |
parent | 8585e4137fbd499c9fbcb465727d6c54437f4345 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/pages')
-rw-r--r-- | app/models/pages/lookup_path.rb | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/app/models/pages/lookup_path.rb b/app/models/pages/lookup_path.rb index 9855731778f..e33d09559ae 100644 --- a/app/models/pages/lookup_path.rb +++ b/app/models/pages/lookup_path.rb @@ -2,6 +2,8 @@ module Pages class LookupPath + include Gitlab::Utils::StrongMemoize + def initialize(project, trim_prefix: nil, domain: nil) @project = project @domain = domain @@ -37,37 +39,28 @@ module Pages attr_reader :project, :trim_prefix, :domain - def artifacts_archive - 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) + strong_memoize(:deployment) do + next unless Feature.enabled?(:pages_serve_from_deployments, project) - project.pages_metadatum.pages_deployment + project.pages_metadatum.pages_deployment + end 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) + return unless deployment&.file - # artifacts archive doesn't support this - file_count = source.file_count if source.respond_to?(:file_count) + return if deployment.file.file_storage? && !Feature.enabled?(:pages_serve_with_zip_file_protocol, project) - global_id = ::Gitlab::GlobalId.build(source, id: source.id).to_s + global_id = ::Gitlab::GlobalId.build(deployment, id: deployment.id).to_s { type: 'zip', - path: source.file.url_or_file_path(expire_at: 1.day.from_now), + path: deployment.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 + sha256: deployment.file_sha256, + file_size: deployment.size, + file_count: deployment.file_count } end |