summaryrefslogtreecommitdiff
path: root/app/services/snippets
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
committerRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
commit6438df3a1e0fb944485cebf07976160184697d72 (patch)
tree00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /app/services/snippets
parent42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff)
downloadgitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'app/services/snippets')
-rw-r--r--app/services/snippets/schedule_bulk_repository_shard_moves_service.rb31
-rw-r--r--app/services/snippets/update_repository_storage_service.rb21
2 files changed, 52 insertions, 0 deletions
diff --git a/app/services/snippets/schedule_bulk_repository_shard_moves_service.rb b/app/services/snippets/schedule_bulk_repository_shard_moves_service.rb
new file mode 100644
index 00000000000..f7bdd0a99a5
--- /dev/null
+++ b/app/services/snippets/schedule_bulk_repository_shard_moves_service.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+module Snippets
+ # Tries to schedule a move for every snippet with repositories on the source shard
+ class ScheduleBulkRepositoryShardMovesService
+ include ScheduleBulkRepositoryShardMovesMethods
+ extend ::Gitlab::Utils::Override
+
+ private
+
+ override :repository_klass
+ def repository_klass
+ SnippetRepository
+ end
+
+ override :container_klass
+ def container_klass
+ Snippet
+ end
+
+ override :container_column
+ def container_column
+ :snippet_id
+ end
+
+ override :schedule_bulk_worker_klass
+ def self.schedule_bulk_worker_klass
+ ::SnippetScheduleBulkRepositoryShardMovesWorker
+ end
+ end
+end
diff --git a/app/services/snippets/update_repository_storage_service.rb b/app/services/snippets/update_repository_storage_service.rb
new file mode 100644
index 00000000000..3addae3b3be
--- /dev/null
+++ b/app/services/snippets/update_repository_storage_service.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+module Snippets
+ class UpdateRepositoryStorageService
+ include UpdateRepositoryStorageMethods
+
+ delegate :snippet, to: :repository_storage_move
+
+ private
+
+ def track_repository(destination_storage_name)
+ snippet.track_snippet_repository(destination_storage_name)
+ end
+
+ def mirror_repositories
+ return unless snippet.repository_exists?
+
+ mirror_repository(type: Gitlab::GlRepository::SNIPPET)
+ end
+ end
+end