summaryrefslogtreecommitdiff
path: root/app/models/project_import_state.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 15:40:28 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 15:40:28 +0000
commitb595cb0c1dec83de5bdee18284abe86614bed33b (patch)
tree8c3d4540f193c5ff98019352f554e921b3a41a72 /app/models/project_import_state.rb
parent2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff)
downloadgitlab-ce-b595cb0c1dec83de5bdee18284abe86614bed33b.tar.gz
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'app/models/project_import_state.rb')
-rw-r--r--app/models/project_import_state.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/app/models/project_import_state.rb b/app/models/project_import_state.rb
index b1c1a5b6697..7711c6d604a 100644
--- a/app/models/project_import_state.rb
+++ b/app/models/project_import_state.rb
@@ -31,6 +31,10 @@ class ProjectImportState < ApplicationRecord
transition started: :finished
end
+ event :cancel do
+ transition [:none, :scheduled, :started] => :canceled
+ end
+
event :fail_op do
transition [:scheduled, :started] => :failed
end
@@ -39,6 +43,7 @@ class ProjectImportState < ApplicationRecord
state :started
state :finished
state :failed
+ state :canceled
after_transition [:none, :finished, :failed] => :scheduled do |state, _|
state.run_after_commit do
@@ -51,7 +56,7 @@ class ProjectImportState < ApplicationRecord
end
end
- after_transition any => :finished do |state, _|
+ after_transition any => [:canceled, :finished] do |state, _|
if state.jid.present?
Gitlab::SidekiqStatus.unset(state.jid)
@@ -59,7 +64,7 @@ class ProjectImportState < ApplicationRecord
end
end
- after_transition any => :failed do |state, _|
+ after_transition any => [:canceled, :failed] do |state, _|
state.project.remove_import_data
end