Commit 9f5dd2de authored by James Lopez's avatar James Lopez

handling errors a bit better on import failure

parent 9c60eca8
...@@ -11,15 +11,15 @@ class ProjectImportWorker ...@@ -11,15 +11,15 @@ class ProjectImportWorker
owner: current_user, owner: current_user,
namespace_id: namespace_id, namespace_id: namespace_id,
project_path: path) project_path: path)
if project
# TODO: Move this to import service
# if result[:status] == :error
# project.update(import_error: result[:message])
# project.import_fail
# return
# end
project.repository.after_import project.repository.after_import
project.import_finish project.import_finish
else
logger.error("There was an error during the import: #{tmpfile}")
end
end
def logger
Sidekiq.logger
end end
end end
...@@ -14,7 +14,8 @@ module Gitlab ...@@ -14,7 +14,8 @@ module Gitlab
end end
def execute def execute
Gitlab::ImportExport::Importer.import(archive_file: @archive_file, storage_path: storage_path) Gitlab::ImportExport::Importer.import(archive_file: @archive_file,
storage_path: storage_path)
project_tree.project if [restore_project_tree, restore_repo, restore_wiki_repo].all? project_tree.project if [restore_project_tree, restore_repo, restore_wiki_repo].all?
end end
...@@ -25,15 +26,20 @@ module Gitlab ...@@ -25,15 +26,20 @@ module Gitlab
end end
def project_tree def project_tree
@project_tree ||= Gitlab::ImportExport::ProjectTreeRestorer.new(path: storage_path, user: @current_user, project_path: @project_path, namespace_id: @namespace.id) @project_tree ||= Gitlab::ImportExport::ProjectTreeRestorer.new(path: storage_path,
user: @current_user,
project_path: @project_path,
namespace_id: @namespace.id)
end end
def restore_repo def restore_repo
Gitlab::ImportExport::RepoRestorer.new(path_to_bundle: repo_path, project: project_tree.project).restore Gitlab::ImportExport::RepoRestorer.new(path_to_bundle: repo_path,
project: project_tree.project).restore
end end
def restore_wiki_repo def restore_wiki_repo
Gitlab::ImportExport::RepoRestorer.new(path_to_bundle: wiki_repo_path, project: ProjectWiki.new(project_tree.project)).restore Gitlab::ImportExport::RepoRestorer.new(path_to_bundle: wiki_repo_path,
project: ProjectWiki.new(project_tree.project)).restore
end end
def storage_path def storage_path
......
...@@ -14,6 +14,8 @@ module Gitlab ...@@ -14,6 +14,8 @@ module Gitlab
@tree_hash = ActiveSupport::JSON.decode(json) @tree_hash = ActiveSupport::JSON.decode(json)
@project_members = @tree_hash.delete('project_members') @project_members = @tree_hash.delete('project_members')
create_relations create_relations
rescue
false
end end
def project def project
...@@ -50,7 +52,7 @@ module Gitlab ...@@ -50,7 +52,7 @@ module Gitlab
project_params: project_params, user: @user, namespace_id: @namespace_id) project_params: project_params, user: @user, namespace_id: @namespace_id)
project.path = @project_path project.path = @project_path
project.name = @project_path project.name = @project_path
project.save project.save!
project project
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment