diff options
Diffstat (limited to 'app/workers/hashed_storage/project_rollback_worker.rb')
-rw-r--r-- | app/workers/hashed_storage/project_rollback_worker.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/workers/hashed_storage/project_rollback_worker.rb b/app/workers/hashed_storage/project_rollback_worker.rb new file mode 100644 index 00000000000..55e1d7ab23e --- /dev/null +++ b/app/workers/hashed_storage/project_rollback_worker.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module HashedStorage + class ProjectRollbackWorker < BaseWorker + include ApplicationWorker + + queue_namespace :hashed_storage + + attr_reader :project_id + + # rubocop: disable CodeReuse/ActiveRecord + def perform(project_id, old_disk_path = nil) + @project_id = project_id # we need to set this in order to create the lease_key + + try_obtain_lease do + project = Project.without_deleted.find_by(id: project_id) + break unless project + + old_disk_path ||= project.disk_path + + ::Projects::HashedStorage::RollbackService.new(project, old_disk_path, logger: logger).execute + end + end + # rubocop: enable CodeReuse/ActiveRecord + end +end |