2020-03-02 21:08:01 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ProjectUpdateRepositoryStorageWorker # rubocop:disable Scalability/IdempotentWorker
|
|
|
|
include ApplicationWorker
|
|
|
|
|
2020-03-31 21:08:05 +00:00
|
|
|
SameFilesystemError = Class.new(StandardError)
|
|
|
|
|
2020-03-14 00:09:30 +00:00
|
|
|
feature_category :gitaly
|
2020-03-02 21:08:01 +00:00
|
|
|
|
|
|
|
def perform(project_id, new_repository_storage_key)
|
|
|
|
project = Project.find(project_id)
|
|
|
|
|
2020-03-31 21:08:05 +00:00
|
|
|
raise SameFilesystemError if same_filesystem?(project.repository.storage, new_repository_storage_key)
|
|
|
|
|
2020-03-02 21:08:01 +00:00
|
|
|
::Projects::UpdateRepositoryStorageService.new(project).execute(new_repository_storage_key)
|
|
|
|
end
|
2020-03-31 21:08:05 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def same_filesystem?(old_storage, new_storage)
|
|
|
|
Gitlab::GitalyClient.filesystem_id(old_storage) == Gitlab::GitalyClient.filesystem_id(new_storage)
|
|
|
|
end
|
2020-03-02 21:08:01 +00:00
|
|
|
end
|