mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-09 20:56:08 +10:00
Merge branch 'fix/gitlab-import-project-file-fix' into 'master'
Fix temp file being deleted after the request while importing a GitLab project Fixes https://gitlab.com/gitlab-com/infrastructure/issues/151 In production, the temporary uploaded file is getting deleted straight after the request so the Sidekiq worker is unable to find it in `/tmp` Also, improved erroring/logging of this situation. See merge request !4894
This commit is contained in:
committed by
Robert Speicher
parent
12af7464cf
commit
ac7cea3084
@@ -23,7 +23,11 @@ module Gitlab
|
||||
private
|
||||
|
||||
def decompress_archive
|
||||
untar_zxf(archive: @archive_file, dir: @shared.export_path)
|
||||
result = untar_zxf(archive: @archive_file, dir: @shared.export_path)
|
||||
|
||||
raise Projects::ImportService::Error.new("Unable to decompress #{@archive_file} into #{@shared.export_path}") unless result
|
||||
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,17 +10,22 @@ module Gitlab
|
||||
end
|
||||
|
||||
def execute
|
||||
Gitlab::ImportExport::FileImporter.import(archive_file: @archive_file,
|
||||
shared: @shared)
|
||||
if check_version! && [project_tree, repo_restorer, wiki_restorer, uploads_restorer].all?(&:restore)
|
||||
if import_file && check_version! && [project_tree, repo_restorer, wiki_restorer, uploads_restorer].all?(&:restore)
|
||||
project_tree.restored_project
|
||||
else
|
||||
raise Projects::ImportService::Error.new(@shared.errors.join(', '))
|
||||
end
|
||||
|
||||
remove_import_file
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def import_file
|
||||
Gitlab::ImportExport::FileImporter.import(archive_file: @archive_file,
|
||||
shared: @shared)
|
||||
end
|
||||
|
||||
def check_version!
|
||||
Gitlab::ImportExport::VersionChecker.check!(shared: @shared)
|
||||
end
|
||||
@@ -59,6 +64,10 @@ module Gitlab
|
||||
def wiki_repo_path
|
||||
File.join(@shared.export_path, 'project.wiki.bundle')
|
||||
end
|
||||
|
||||
def remove_import_file
|
||||
FileUtils.rm_rf(@archive_file)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user