summaryrefslogtreecommitdiff
path: root/app/services/projects/hashed_storage
diff options
context:
space:
mode:
authorGabriel Mazetto <brodock@gmail.com>2019-01-15 04:30:55 +0100
committerGabriel Mazetto <brodock@gmail.com>2019-01-25 20:26:35 +0100
commitcf52488ccba8913027334c16892ee1fce1241169 (patch)
treee7d0b15ba32d9a984a86a9c356c5382647123e48 /app/services/projects/hashed_storage
parentc2c34eba62f26bed8cad8b07934e14b4519eef7c (diff)
downloadgitlab-ce-cf52488ccba8913027334c16892ee1fce1241169.tar.gz
Move MigrationService to HashedStorage module
This is part of the refactor to include a RollbackService into HashedStorage module
Diffstat (limited to 'app/services/projects/hashed_storage')
-rw-r--r--app/services/projects/hashed_storage/migration_service.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/services/projects/hashed_storage/migration_service.rb b/app/services/projects/hashed_storage/migration_service.rb
new file mode 100644
index 00000000000..140c35bdd52
--- /dev/null
+++ b/app/services/projects/hashed_storage/migration_service.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+module Projects
+ module HashedStorage
+ class MigrationService < BaseService
+ attr_reader :logger, :old_disk_path
+
+ def initialize(project, old_disk_path, logger: nil)
+ @project = project
+ @old_disk_path = old_disk_path
+ @logger = logger || Rails.logger
+ end
+
+ def execute
+ # Migrate repository from Legacy to Hashed Storage
+ unless project.hashed_storage?(:repository)
+ return unless HashedStorage::MigrateRepositoryService.new(project, old_disk_path, logger: logger).execute
+ end
+
+ # Migrate attachments from Legacy to Hashed Storage
+ unless project.hashed_storage?(:attachments)
+ HashedStorage::MigrateAttachmentsService.new(project, old_disk_path, logger: logger).execute
+ end
+
+ true
+ end
+ end
+ end
+end