parent
28c6a6b044
commit
34e16110e0
1 changed files with 15 additions and 14 deletions
|
@ -6,8 +6,9 @@ module Ci
|
||||||
job.trace.read do |stream|
|
job.trace.read do |stream|
|
||||||
break unless stream.file?
|
break unless stream.file?
|
||||||
|
|
||||||
clone_file!(stream.path, JobArtifactUploader.workhorse_upload_path) do |clone_path|
|
temp_file!(JobArtifactUploader.workhorse_upload_path) do |temp_path|
|
||||||
create_job_trace!(job, clone_path)
|
FileUtils.copy(stream.path, temp_path)
|
||||||
|
create_job_trace!(job, temp_path)
|
||||||
FileUtils.rm(stream.path)
|
FileUtils.rm(stream.path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -16,21 +17,21 @@ module Ci
|
||||||
private
|
private
|
||||||
|
|
||||||
def create_job_trace!(job, path)
|
def create_job_trace!(job, path)
|
||||||
File.open(path) do |stream|
|
|
||||||
job.create_job_artifacts_trace!(
|
job.create_job_artifacts_trace!(
|
||||||
project: job.project,
|
project: job.project,
|
||||||
file_type: :trace,
|
file_type: :trace,
|
||||||
file: stream)
|
file: UploadedFile.new(path, 'job.log', 'application/octet-stream')
|
||||||
end
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def clone_file!(src_path, temp_dir)
|
def temp_file!(temp_dir)
|
||||||
FileUtils.mkdir_p(temp_dir)
|
FileUtils.mkdir_p(temp_dir)
|
||||||
Dir.mktmpdir('tmp-trace', temp_dir) do |dir_path|
|
temp_file = Tempfile.new('trace-tmp-', temp_dir)
|
||||||
temp_path = File.join(dir_path, "job.log")
|
temp_file&.close
|
||||||
FileUtils.copy(src_path, temp_path)
|
yield(temp_file.path)
|
||||||
yield(temp_path)
|
ensure
|
||||||
end
|
temp_file&.close
|
||||||
|
temp_file&.unlink
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue