Skip to content
Snippets Groups Projects
Commit 46b89a27 authored by James Lopez's avatar James Lopez
Browse files

Fix tmp file being deleted after the request plus some cleanup and improved...

Fix tmp file being deleted after the request plus some cleanup and improved erroring for this situation
parent 4477dc24
No related branches found
No related tags found
1 merge request!4894Fix temp file being deleted after the request while importing a GitLab project
Pipeline #
Loading
@@ -19,6 +19,7 @@ v 8.9.1
Loading
@@ -19,6 +19,7 @@ v 8.9.1
- Fix 404 when accessing pipelines as guest user on public projects - Fix 404 when accessing pipelines as guest user on public projects
- Fix mobile Safari bug where horizontal nav arrows would flicker on scroll - Fix mobile Safari bug where horizontal nav arrows would flicker on scroll
- Fix in auto merge when pipeline is nil - Fix in auto merge when pipeline is nil
- Fix GitLab import project deleting imported file straight after being uploaded
   
v 8.9.0 v 8.9.0
- Fix builds API response not including commit data - Fix builds API response not including commit data
Loading
Loading
Loading
@@ -12,9 +12,13 @@ class Import::GitlabProjectsController < Import::BaseController
Loading
@@ -12,9 +12,13 @@ class Import::GitlabProjectsController < Import::BaseController
return redirect_back_or_default(options: { alert: "You need to upload a GitLab project export archive." }) return redirect_back_or_default(options: { alert: "You need to upload a GitLab project export archive." })
end end
   
imported_file = params[:file].path + "-import"
FileUtils.copy_entry(params[:file].path, imported_file)
@project = Gitlab::ImportExport::ProjectCreator.new(project_params[:namespace_id], @project = Gitlab::ImportExport::ProjectCreator.new(project_params[:namespace_id],
current_user, current_user,
File.expand_path(project_params[:file].path), File.expand_path(imported_file),
project_params[:path]).execute project_params[:path]).execute
   
if @project.saved? if @project.saved?
Loading
Loading
Loading
@@ -23,7 +23,11 @@ module Gitlab
Loading
@@ -23,7 +23,11 @@ module Gitlab
private private
   
def decompress_archive 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 end
end end
Loading
Loading
Loading
@@ -10,17 +10,22 @@ module Gitlab
Loading
@@ -10,17 +10,22 @@ module Gitlab
end end
   
def execute def execute
Gitlab::ImportExport::FileImporter.import(archive_file: @archive_file, if import_file && check_version! && [project_tree, repo_restorer, wiki_restorer, uploads_restorer].all?(&:restore)
shared: @shared)
if check_version! && [project_tree, repo_restorer, wiki_restorer, uploads_restorer].all?(&:restore)
project_tree.restored_project project_tree.restored_project
else else
raise Projects::ImportService::Error.new(@shared.errors.join(', ')) raise Projects::ImportService::Error.new(@shared.errors.join(', '))
end end
remove_import_file
end end
   
private private
   
def import_file
Gitlab::ImportExport::FileImporter.import(archive_file: @archive_file,
shared: @shared)
end
def check_version! def check_version!
Gitlab::ImportExport::VersionChecker.check!(shared: @shared) Gitlab::ImportExport::VersionChecker.check!(shared: @shared)
end end
Loading
@@ -59,6 +64,10 @@ module Gitlab
Loading
@@ -59,6 +64,10 @@ module Gitlab
def wiki_repo_path def wiki_repo_path
File.join(@shared.export_path, 'project.wiki.bundle') File.join(@shared.export_path, 'project.wiki.bundle')
end end
def remove_import_file
FileUtils.rm_rf(@archive_file)
end
end end
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment