Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/import_export/importer.rb')
-rw-r--r--lib/gitlab/import_export/importer.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/gitlab/import_export/importer.rb b/lib/gitlab/import_export/importer.rb
index b1219384732..7b8689069d8 100644
--- a/lib/gitlab/import_export/importer.rb
+++ b/lib/gitlab/import_export/importer.rb
@@ -24,8 +24,14 @@ module Gitlab
raise Projects::ImportService::Error.new(shared.errors.to_sentence)
end
rescue => e
+ # If some exception was raised could mean that the SnippetsRepoRestorer
+ # was not called. This would leave us with snippets without a repository.
+ # This is a state we don't want them to be, so we better delete them.
+ remove_non_migrated_snippets
+
raise Projects::ImportService::Error.new(e.message)
ensure
+ remove_base_tmp_dir
remove_import_file
end
@@ -148,6 +154,18 @@ module Gitlab
::Project.find_by_full_path("#{project.namespace.full_path}/#{original_path}")
end
end
+
+ def remove_base_tmp_dir
+ FileUtils.rm_rf(@shared.base_path)
+ end
+
+ def remove_non_migrated_snippets
+ project
+ .snippets
+ .left_joins(:snippet_repository)
+ .where(snippet_repositories: { snippet_id: nil })
+ .delete_all
+ end
end
end
end