diff options
author | Douwe Maan <douwe@selenight.nl> | 2018-05-07 21:35:51 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2018-05-07 21:36:11 +0300 |
commit | cfa798da5361128d9473ed170062586dea9525ae (patch) | |
tree | a51ea89785e6909a72eb577439e719768cd9d1c4 /app | |
parent | bb3b7acb068bba6b841c453b7edac441c86c2650 (diff) |
Force creation of new import_state when setting an import state field
Diffstat (limited to 'app')
-rw-r--r-- | app/models/project.rb | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 37f1fcea280..1e3de535c18 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -647,8 +647,8 @@ class Project < ActiveRecord::Base } end - def ensure_import_state - return if self[:import_status] == 'none' || self[:import_status].nil? + def ensure_import_state(force: false) + return if !force && (self[:import_status] == 'none' || self[:import_status].nil?) return unless import_state.nil? create_import_state(import_state_args) @@ -657,39 +657,39 @@ class Project < ActiveRecord::Base end def import_schedule - ensure_import_state + ensure_import_state(force: true) - import_state&.schedule + import_state.schedule end def force_import_start - ensure_import_state + ensure_import_state(force: true) - import_state&.force_start + import_state.force_start end def import_start - ensure_import_state + ensure_import_state(force: true) - import_state&.start + import_state.start end def import_fail - ensure_import_state + ensure_import_state(force: true) - import_state&.fail_op + import_state.fail_op end def import_finish - ensure_import_state + ensure_import_state(force: true) - import_state&.finish + import_state.finish end def import_jid=(new_jid) - ensure_import_state + ensure_import_state(force: true) - import_state&.jid = new_jid + import_state.jid = new_jid end def import_jid @@ -699,9 +699,9 @@ class Project < ActiveRecord::Base end def import_error=(new_error) - ensure_import_state + ensure_import_state(force: true) - import_state&.last_error = new_error + import_state.last_error = new_error end def import_error @@ -711,9 +711,9 @@ class Project < ActiveRecord::Base end def import_status=(new_status) - ensure_import_state + ensure_import_state(force: true) - import_state&.status = new_status + import_state.status = new_status end def import_status |