debian-mirror-gitlab/app/services/projects/hashed_storage_migration_service.rb

28 lines
804 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
module Projects
class HashedStorageMigrationService < BaseService
2018-11-18 11:00:15 +05:30
attr_reader :logger, :old_disk_path
2018-03-17 18:26:18 +05:30
2018-11-18 11:00:15 +05:30
def initialize(project, old_disk_path, logger: nil)
2018-03-17 18:26:18 +05:30
@project = project
2018-11-18 11:00:15 +05:30
@old_disk_path = old_disk_path
2018-03-17 18:26:18 +05:30
@logger = logger || Rails.logger
end
def execute
# Migrate repository from Legacy to Hashed Storage
unless project.hashed_storage?(:repository)
2018-11-18 11:00:15 +05:30
return unless HashedStorage::MigrateRepositoryService.new(project, old_disk_path, logger: logger).execute
2018-03-17 18:26:18 +05:30
end
# Migrate attachments from Legacy to Hashed Storage
unless project.hashed_storage?(:attachments)
2018-11-18 11:00:15 +05:30
HashedStorage::MigrateAttachmentsService.new(project, old_disk_path, logger: logger).execute
2018-03-17 18:26:18 +05:30
end
2018-11-18 11:00:15 +05:30
true
2018-03-17 18:26:18 +05:30
end
end
end