mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-13 14:46:05 +10:00
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
35 lines
751 B
Ruby
35 lines
751 B
Ruby
module Gitlab
|
|
module ImportExport
|
|
class FileImporter
|
|
include Gitlab::ImportExport::CommandLineUtil
|
|
|
|
def self.import(*args)
|
|
new(*args).import
|
|
end
|
|
|
|
def initialize(archive_file:, shared:)
|
|
@archive_file = archive_file
|
|
@shared = shared
|
|
end
|
|
|
|
def import
|
|
FileUtils.mkdir_p(@shared.export_path)
|
|
decompress_archive
|
|
rescue => e
|
|
@shared.error(e)
|
|
false
|
|
end
|
|
|
|
private
|
|
|
|
def decompress_archive
|
|
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
|