diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /app/models/pages | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'app/models/pages')
-rw-r--r-- | app/models/pages/lookup_path.rb | 14 | ||||
-rw-r--r-- | app/models/pages/virtual_domain.rb | 11 |
2 files changed, 21 insertions, 4 deletions
diff --git a/app/models/pages/lookup_path.rb b/app/models/pages/lookup_path.rb index 84928468ad1..c6781f8f6e3 100644 --- a/app/models/pages/lookup_path.rb +++ b/app/models/pages/lookup_path.rb @@ -4,6 +4,8 @@ module Pages class LookupPath include Gitlab::Utils::StrongMemoize + LegacyStorageDisabledError = Class.new(::StandardError) + def initialize(project, trim_prefix: nil, domain: nil) @project = project @domain = domain @@ -24,7 +26,7 @@ module Pages end def source - zip_source || file_source + zip_source || legacy_source end def prefix @@ -52,6 +54,8 @@ module Pages return if deployment.file.file_storage? && !Feature.enabled?(:pages_serve_with_zip_file_protocol, project) + return if deployment.migrated? && !Feature.enabled?(:pages_serve_from_migrated_zip, project) + global_id = ::Gitlab::GlobalId.build(deployment, id: deployment.id).to_s { @@ -64,11 +68,17 @@ module Pages } end - def file_source + def legacy_source + raise LegacyStorageDisabledError unless Feature.enabled?(:pages_serve_from_legacy_storage, default_enabled: true) + { type: 'file', path: File.join(project.full_path, 'public/') } + rescue LegacyStorageDisabledError => e + Gitlab::ErrorTracking.track_exception(e) + + nil end end end diff --git a/app/models/pages/virtual_domain.rb b/app/models/pages/virtual_domain.rb index 7e42b8e6ae2..90cb8253b52 100644 --- a/app/models/pages/virtual_domain.rb +++ b/app/models/pages/virtual_domain.rb @@ -17,9 +17,16 @@ module Pages end def lookup_paths - projects.map do |project| + paths = projects.map do |project| project.pages_lookup_path(trim_prefix: trim_prefix, domain: domain) - end.sort_by(&:prefix).reverse + end + + # TODO: remove in https://gitlab.com/gitlab-org/gitlab/-/issues/297524 + # source can only be nil if pages_serve_from_legacy_storage FF is disabled + # we can remove this filtering once we remove legacy storage + paths = paths.select(&:source) + + paths.sort_by(&:prefix).reverse end private |