summaryrefslogtreecommitdiff
path: root/app/services/projects/hashed_storage_migration_service.rb
blob: a0e734005f8404c792da18182d018bc82e546319 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

module Projects
  class HashedStorageMigrationService < 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