summaryrefslogtreecommitdiff
path: root/app/models/pages/lookup_path.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/pages/lookup_path.rb')
-rw-r--r--app/models/pages/lookup_path.rb36
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