Commit 40bc0825 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'mk/fix-attachments-when-sync-object-storage-disabled' into 'master'

Geo: Fix replicable attachments when sync object storage is disabled

See merge request gitlab-org/gitlab!36904
parents 7a987cfe 30b5179c
...@@ -3,12 +3,9 @@ ...@@ -3,12 +3,9 @@
module Geo::SelectiveSync module Geo::SelectiveSync
extend ActiveSupport::Concern extend ActiveSupport::Concern
# @return [ActiveRecord::Relation<Upload>] scope of everything that should be synced
def attachments def attachments
if selective_sync? attachments_selective_sync_scope.merge(attachments_object_storage_scope)
uploads_model.where(group_attachments.or(project_attachments).or(other_attachments))
else
uploads_model.all
end
end end
def projects_outside_selected_namespaces def projects_outside_selected_namespaces
...@@ -49,6 +46,22 @@ module Geo::SelectiveSync ...@@ -49,6 +46,22 @@ module Geo::SelectiveSync
private private
# @return [ActiveRecord::Relation<Upload>] scope observing object storage settings
def attachments_object_storage_scope
return uploads_model.all if sync_object_storage?
uploads_model.with_files_stored_locally
end
# @return [ActiveRecord::Relation<Upload>] scope observing selective sync settings
def attachments_selective_sync_scope
if selective_sync?
uploads_model.where(group_attachments.or(project_attachments).or(other_attachments))
else
uploads_model.all
end
end
def selected_namespaces_and_descendants def selected_namespaces_and_descendants
relation = selected_namespaces_and_descendants_cte.apply_to(namespaces_model.all) relation = selected_namespaces_and_descendants_cte.apply_to(namespaces_model.all)
read_only(relation) read_only(relation)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment