Read about our upcoming Code of Conduct on this issue

project_migrate_worker.rb 776 Bytes
Newer Older
1
2
3
# frozen_string_literal: true

module HashedStorage
4
  class ProjectMigrateWorker < BaseWorker
5
6
7
8
    include ApplicationWorker

    queue_namespace :hashed_storage

9
10
    attr_reader :project_id

11
12
    # rubocop: disable CodeReuse/ActiveRecord
    def perform(project_id, old_disk_path = nil)
13
      @project_id = project_id # we need to set this in order to create the lease_key
14

15
      try_obtain_lease do
16
        project = Project.without_deleted.find_by(id: project_id)
17
        break unless project && project.storage_upgradable?
18

19
        old_disk_path ||= Storage::LegacyProject.new(project).disk_path
20
21
22
23
24
25
26

        ::Projects::HashedStorage::MigrationService.new(project, old_disk_path, logger: logger).execute
      end
    end
    # rubocop: enable CodeReuse/ActiveRecord
  end
end