Class: Gitlab::ImportExport::Group::TreeRestorer

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/import_export/group/tree_restorer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user:, shared:, group:) ⇒ TreeRestorer

Returns a new instance of TreeRestorer.



11
12
13
14
15
16
# File 'lib/gitlab/import_export/group/tree_restorer.rb', line 11

def initialize(user:, shared:, group:)
  @user = user
  @shared = shared
  @top_level_group = group
  @groups_mapping = {}
end

Instance Attribute Details

#groups_mappingObject (readonly)

Returns the value of attribute groups_mapping.



9
10
11
# File 'lib/gitlab/import_export/group/tree_restorer.rb', line 9

def groups_mapping
  @groups_mapping
end

#sharedObject (readonly)

Returns the value of attribute shared.



9
10
11
# File 'lib/gitlab/import_export/group/tree_restorer.rb', line 9

def shared
  @shared
end

#userObject (readonly)

Returns the value of attribute user.



9
10
11
# File 'lib/gitlab/import_export/group/tree_restorer.rb', line 9

def user
  @user
end

Instance Method Details

#restoreObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gitlab/import_export/group/tree_restorer.rb', line 18

def restore
  group_ids = relation_reader.consume_relation('groups', '_all').map { |value, _idx| Integer(value) }
  root_group_id = group_ids.delete_at(0)

  process_root(root_group_id)

  group_ids.each do |group_id|
    process_child(group_id)
  end

  true
rescue StandardError => e
  shared.error(e)
  false
end