Class: Gitlab::ImportExport::Project::TreeRestorer
- Inherits:
-
Object
- Object
- Gitlab::ImportExport::Project::TreeRestorer
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/import_export/project/tree_restorer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#shared ⇒ Object
readonly
Returns the value of attribute shared.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(user:, shared:, project:) ⇒ TreeRestorer
constructor
A new instance of TreeRestorer.
- #restore ⇒ Object
Constructor Details
#initialize(user:, shared:, project:) ⇒ TreeRestorer
Returns a new instance of TreeRestorer.
13 14 15 16 17 |
# File 'lib/gitlab/import_export/project/tree_restorer.rb', line 13 def initialize(user:, shared:, project:) @user = user @shared = shared @project = project end |
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
11 12 13 |
# File 'lib/gitlab/import_export/project/tree_restorer.rb', line 11 def project @project end |
#shared ⇒ Object (readonly)
Returns the value of attribute shared.
10 11 12 |
# File 'lib/gitlab/import_export/project/tree_restorer.rb', line 10 def shared @shared end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
9 10 11 |
# File 'lib/gitlab/import_export/project/tree_restorer.rb', line 9 def user @user end |
Instance Method Details
#restore ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/gitlab/import_export/project/tree_restorer.rb', line 19 def restore unless relation_reader.exist? raise Gitlab::ImportExport::Error, 'invalid import format' end @project_attributes = relation_reader.consume_attributes(importable_path) @project_members = relation_reader.consume_relation(importable_path, 'project_members') .map(&:first) # ensure users are mapped before tree restoration # so that even if there is no content to associate # users with, they are still added to the project members_mapper.map if relation_tree_restorer.restore import_failure_service.with_retry(action: 'set_latest_merge_request_diff_ids!') do @project.merge_requests.set_latest_merge_request_diff_ids! end true else false end rescue StandardError => e @shared.error(e) false end |