Class: Groups::ImportExport::ImportService
- Inherits:
-
Object
- Object
- Groups::ImportExport::ImportService
- Defined in:
- app/services/groups/import_export/import_service.rb
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #async_execute ⇒ Object
- #execute ⇒ Object
-
#initialize(group:, user:) ⇒ ImportService
constructor
A new instance of ImportService.
Constructor Details
#initialize(group:, user:) ⇒ ImportService
Returns a new instance of ImportService.
8 9 10 11 12 13 |
# File 'app/services/groups/import_export/import_service.rb', line 8 def initialize(group:, user:) @group = group @current_user = user @shared = Gitlab::ImportExport::Shared.new(@group) @logger = Gitlab::Import::Logger.build end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user
6 7 8 |
# File 'app/services/groups/import_export/import_service.rb', line 6 def current_user @current_user end |
#group ⇒ Object (readonly)
Returns the value of attribute group
6 7 8 |
# File 'app/services/groups/import_export/import_service.rb', line 6 def group @group end |
#params ⇒ Object (readonly)
Returns the value of attribute params
6 7 8 |
# File 'app/services/groups/import_export/import_service.rb', line 6 def params @params end |
Instance Method Details
#async_execute ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/services/groups/import_export/import_service.rb', line 15 def async_execute group_import_state = GroupImportState.safe_find_or_create_by!(group: group) jid = GroupImportWorker.perform_async(current_user.id, group.id) if jid.present? group_import_state.update!(jid: jid) else group_import_state.fail_op('Failed to schedule import job') false end end |
#execute ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/services/groups/import_export/import_service.rb', line 28 def execute if && import_file && restorer.restore notify_success @group else notify_error! end ensure remove_base_tmp_dir remove_import_file end |