Commit aae947cb authored by Tiago Botelho's avatar Tiago Botelho Committed by Z.J. van de Weg

Fixes race condition in project uploads

Originally picked as: 3fc0dbcbebcd470fe14f8b5fb7ad55dc3912402e. But
given the internals changed, this was changed now. The changelog was
removed too.
parent 7c5757ad
...@@ -22,8 +22,11 @@ module Projects ...@@ -22,8 +22,11 @@ module Projects
private private
def import_upload_path def import_upload_path
@import_upload_path ||= Gitlab::ImportExport @import_upload_path ||= Gitlab::ImportExport.import_upload_path(filename: tmp_filename)
.import_upload_path(filename: "#{params[:namespace_id]}-#{params[:path]}") end
def tmp_filename
"#{SecureRandom.hex}_#{params[:path]}"
end end
def file def file
......
...@@ -15,9 +15,7 @@ module Gitlab ...@@ -15,9 +15,7 @@ module Gitlab
end end
def import_upload_path(filename:) def import_upload_path(filename:)
milliseconds = Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond) File.join(storage_path, 'uploads', filename)
File.join(storage_path, 'uploads', "#{milliseconds}-#{filename}")
end end
def project_filename def project_filename
......
...@@ -31,6 +31,7 @@ feature 'Import/Export - project import integration test', js: true do ...@@ -31,6 +31,7 @@ feature 'Import/Export - project import integration test', js: true do
expect(page).to have_content('GitLab project export') 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(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) attach_file('file', file)
......
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