Fixes race condition in project uploads
Originally picked as: 3fc0dbcbebcd470fe14f8b5fb7ad55dc3912402e. But given the internals changed, this was changed now. The changelog was removed too.
This commit is contained in:
parent
7c5757ad9a
commit
aae947cb1c
3 changed files with 7 additions and 5 deletions
|
@ -22,8 +22,11 @@ module Projects
|
|||
private
|
||||
|
||||
def import_upload_path
|
||||
@import_upload_path ||= Gitlab::ImportExport
|
||||
.import_upload_path(filename: "#{params[:namespace_id]}-#{params[:path]}")
|
||||
@import_upload_path ||= Gitlab::ImportExport.import_upload_path(filename: tmp_filename)
|
||||
end
|
||||
|
||||
def tmp_filename
|
||||
"#{SecureRandom.hex}_#{params[:path]}"
|
||||
end
|
||||
|
||||
def file
|
||||
|
|
|
@ -15,9 +15,7 @@ module Gitlab
|
|||
end
|
||||
|
||||
def import_upload_path(filename:)
|
||||
milliseconds = Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond)
|
||||
|
||||
File.join(storage_path, 'uploads', "#{milliseconds}-#{filename}")
|
||||
File.join(storage_path, 'uploads', filename)
|
||||
end
|
||||
|
||||
def project_filename
|
||||
|
|
|
@ -31,6 +31,7 @@ feature 'Import/Export - project import integration test', js: true do
|
|||
|
||||
expect(page).to have_content('GitLab project export')
|
||||
expect(URI.parse(current_url).query).to eq("namespace_id=#{namespace.id}&path=test-project-path")
|
||||
expect(Gitlab::ImportExport).to receive(:import_upload_path).with(filename: /\A[0-9a-f]{32}_test_project_export\.tar\.gz\z/).and_call_original
|
||||
|
||||
attach_file('file', file)
|
||||
|
||||
|
|
Loading…
Reference in a new issue