diff options
author | James Lopez <james@jameslopez.es> | 2017-09-02 16:17:41 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-09-05 17:47:44 +0200 |
commit | 025a268881d5441c191474759a84c3a28c6d1965 (patch) | |
tree | 14a1cdba7af5c4639d015d1985cdac3f63bec3fd | |
parent | 690b9865f48c41f16dd0c70b37dbcc66fee4c67c (diff) | |
download | gitlab-ce-025a268881d5441c191474759a84c3a28c6d1965.tar.gz |
more refactoring
-rw-r--r-- | lib/gitlab/import_export/project_tree_restorer.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/gitlab/import_export/project_tree_restorer.rb b/lib/gitlab/import_export/project_tree_restorer.rb index a288b7a5b56..b53de2a33e1 100644 --- a/lib/gitlab/import_export/project_tree_restorer.rb +++ b/lib/gitlab/import_export/project_tree_restorer.rb @@ -80,6 +80,7 @@ module Gitlab def save_relation_hash(relation_hash_batch, relation_key) relation_hash = create_relation(relation_key, relation_hash_batch) + @saved << restored_project.append_or_update_attribute(relation_key, relation_hash) @restored_project = nil @project = nil @@ -115,7 +116,8 @@ module Gitlab # issue, finds any subrelations such as notes, creates them and assign them back to the hash # # Recursively calls this method if the sub-relation is a hash containing more sub-relations - def create_sub_relations(relation, tree_hash) + def create_sub_relations(relation, tree_hash, save = true) + tree_hash = tree_hash.dup relation_key = relation.keys.first.to_s return if tree_hash[relation_key].blank? @@ -124,13 +126,13 @@ module Gitlab # We just use author to get the user ID, do not attempt to create an instance. next if sub_relation == :author - create_sub_relations(sub_relation, relation_item) if sub_relation.is_a?(Hash) + create_sub_relations(sub_relation, relation_item, false) if sub_relation.is_a?(Hash) relation_hash, sub_relation = assign_relation_hash(relation_item, sub_relation) relation_item[sub_relation.to_s] = create_relation(sub_relation, relation_hash) unless relation_hash.blank? end - save_relation_hash(relation_item, relation_key) + save_relation_hash([relation_item], relation_key) if save end end |