debian-mirror-gitlab/app/services/projects/hashed_storage/migration_service.rb

40 lines
1.1 KiB
Ruby
Raw Normal View History

2019-03-02 22:35:43 +05:30
# 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 || Gitlab::AppLogger
end
def execute
# Migrate repository from Legacy to Hashed Storage
unless project.hashed_storage?(:repository)
2019-12-26 22:10:19 +05:30
return false unless migrate_repository_service.execute
2019-03-02 22:35:43 +05:30
end
# Migrate attachments from Legacy to Hashed Storage
unless project.hashed_storage?(:attachments)
2019-12-26 22:10:19 +05:30
return false unless migrate_attachments_service.execute
2019-03-02 22:35:43 +05:30
end
true
end
private
2019-12-26 22:10:19 +05:30
def migrate_repository_service
HashedStorage::MigrateRepositoryService.new(project: project, old_disk_path: old_disk_path, logger: logger)
2019-03-02 22:35:43 +05:30
end
2019-12-26 22:10:19 +05:30
def migrate_attachments_service
HashedStorage::MigrateAttachmentsService.new(project: project, old_disk_path: old_disk_path, logger: logger)
2019-03-02 22:35:43 +05:30
end
end
end
end