2018-07-17 16:50:37 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-06 05:16:26 +00:00
|
|
|
module Projects
|
|
|
|
class HashedStorageMigrationService < BaseService
|
2018-08-03 14:34:28 +00:00
|
|
|
attr_reader :logger, :old_disk_path
|
2017-11-15 13:42:38 +00:00
|
|
|
|
2018-08-03 14:34:28 +00:00
|
|
|
def initialize(project, old_disk_path, logger: nil)
|
2017-09-06 05:16:26 +00:00
|
|
|
@project = project
|
2018-08-03 14:34:28 +00:00
|
|
|
@old_disk_path = old_disk_path
|
2017-11-13 14:15:42 +00:00
|
|
|
@logger = logger || Rails.logger
|
2017-09-06 05:16:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2017-11-13 14:15:42 +00:00
|
|
|
# Migrate repository from Legacy to Hashed Storage
|
|
|
|
unless project.hashed_storage?(:repository)
|
2018-08-03 14:34:28 +00:00
|
|
|
return unless HashedStorage::MigrateRepositoryService.new(project, old_disk_path, logger: logger).execute
|
2017-09-06 05:16:26 +00:00
|
|
|
end
|
2017-11-15 13:42:38 +00:00
|
|
|
|
|
|
|
# Migrate attachments from Legacy to Hashed Storage
|
|
|
|
unless project.hashed_storage?(:attachments)
|
2018-08-03 14:34:28 +00:00
|
|
|
HashedStorage::MigrateAttachmentsService.new(project, old_disk_path, logger: logger).execute
|
2017-11-15 13:42:38 +00:00
|
|
|
end
|
2018-08-03 14:34:28 +00:00
|
|
|
|
|
|
|
true
|
2017-09-06 05:16:26 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|