Commit a9a8dd14 authored by Thong Kuah's avatar Thong Kuah

Merge branch '346825-fix-uploads-in-docker' into 'master'

Fix uploads in CI becoming empty files

See merge request gitlab-org/gitlab!75594
parents 7266d8f4 de4b15ee
...@@ -24,6 +24,8 @@ RSpec.describe Ci::JobArtifacts::CreateService do ...@@ -24,6 +24,8 @@ RSpec.describe Ci::JobArtifacts::CreateService do
def file_to_upload(path, params = {}) def file_to_upload(path, params = {})
upload = Tempfile.new('upload') upload = Tempfile.new('upload')
FileUtils.copy(path, upload.path) FileUtils.copy(path, upload.path)
# This is a workaround for https://github.com/docker/for-linux/issues/1015
FileUtils.touch(upload.path)
UploadedFile.new(upload.path, **params) UploadedFile.new(upload.path, **params)
end end
......
...@@ -480,3 +480,14 @@ Rugged::Settings['search_path_global'] = Rails.root.join('tmp/tests').to_s ...@@ -480,3 +480,14 @@ Rugged::Settings['search_path_global'] = Rails.root.join('tmp/tests').to_s
# Initialize FactoryDefault to use create_default helper # Initialize FactoryDefault to use create_default helper
TestProf::FactoryDefault.init TestProf::FactoryDefault.init
module TouchRackUploadedFile
def initialize_from_file_path(path)
super
# This is a no-op workaround for https://github.com/docker/for-linux/issues/1015
File.utime @tempfile.atime, @tempfile.mtime, @tempfile.path # rubocop:disable Gitlab/ModuleWithInstanceVariables
end
end
Rack::Test::UploadedFile.prepend(TouchRackUploadedFile)
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