diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-02-24 01:44:45 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-02-24 01:44:45 +0900 |
commit | aa603812e3d4917107af69d114ea1ab4050aebb7 (patch) | |
tree | 42096b2dc66a6a8b6d46aecca9699f4c22d918aa /app | |
parent | 76d70841926d21832040d6e7801ed67a7e7f88ee (diff) | |
download | gitlab-ce-aa603812e3d4917107af69d114ea1ab4050aebb7.tar.gz |
Bring back the initial commit
Diffstat (limited to 'app')
-rw-r--r-- | app/services/ci/create_trace_artifact_service.rb | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/app/services/ci/create_trace_artifact_service.rb b/app/services/ci/create_trace_artifact_service.rb index baa33de2857..3a6d0f6f8e5 100644 --- a/app/services/ci/create_trace_artifact_service.rb +++ b/app/services/ci/create_trace_artifact_service.rb @@ -4,29 +4,30 @@ module Ci return if job.job_artifacts_trace job.trace.read do |stream| - return unless stream.file? # rubocop:disable Lint/NonLocalExitFromIterator + break unless stream.file? - temp_file!(stream.path, JobArtifactUploader.workhorse_upload_path) do |temp_path| - job.create_job_artifacts_trace!( - project: job.project, - file_type: :trace, - file: UploadedFile.new(temp_path, 'job.log', 'application/octet-stream') - ) + temp_file!(JobArtifactUploader.workhorse_upload_path) do |temp_path| + FileUtils.cp(stream.path, temp_path) + create_job_trace!(job, temp_path) + FileUtils.rm(stream.path) end - - raise 'Trace artifact not found' unless job.job_artifacts_trace.file.exists? - - FileUtils.rm(stream.path) end end private - def temp_file!(src_file, temp_dir) + def create_job_trace!(job, path) + job.create_job_artifacts_trace!( + project: job.project, + file_type: :trace, + file: UploadedFile.new(path, 'job.log', 'application/octet-stream') + ) + end + + def temp_file!(temp_dir) FileUtils.mkdir_p(temp_dir) temp_file = Tempfile.new('trace-tmp-', temp_dir) temp_file&.close - FileUtils.cp(src_file, temp_file.path) yield(temp_file.path) ensure temp_file&.close |