Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
28c6a6b0
Commit
28c6a6b0
authored
Feb 24, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Dir.mktmpdir
parent
4a54cc4c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
15 deletions
+14
-15
app/services/ci/create_trace_artifact_service.rb
app/services/ci/create_trace_artifact_service.rb
+14
-15
No files found.
app/services/ci/create_trace_artifact_service.rb
View file @
28c6a6b0
...
@@ -6,9 +6,8 @@ module Ci
...
@@ -6,9 +6,8 @@ module Ci
job
.
trace
.
read
do
|
stream
|
job
.
trace
.
read
do
|
stream
|
break
unless
stream
.
file?
break
unless
stream
.
file?
temp_file!
(
JobArtifactUploader
.
workhorse_upload_path
)
do
|
temp_path
|
clone_file!
(
stream
.
path
,
JobArtifactUploader
.
workhorse_upload_path
)
do
|
clone_path
|
FileUtils
.
copy
(
stream
.
path
,
temp_path
)
create_job_trace!
(
job
,
clone_path
)
create_job_trace!
(
job
,
temp_path
)
FileUtils
.
rm
(
stream
.
path
)
FileUtils
.
rm
(
stream
.
path
)
end
end
end
end
...
@@ -17,21 +16,21 @@ module Ci
...
@@ -17,21 +16,21 @@ module Ci
private
private
def
create_job_trace!
(
job
,
path
)
def
create_job_trace!
(
job
,
path
)
job
.
create_job_artifacts_trace!
(
File
.
open
(
path
)
do
|
stream
|
project:
job
.
project
,
job
.
create_job_artifacts_trace!
(
file_type: :trace
,
project:
job
.
project
,
file:
UploadedFile
.
new
(
path
,
'job.log'
,
'application/octet-stream'
)
file_type: :trace
,
)
file:
stream
)
end
end
end
def
temp_file!
(
temp_dir
)
def
clone_file!
(
src_path
,
temp_dir
)
FileUtils
.
mkdir_p
(
temp_dir
)
FileUtils
.
mkdir_p
(
temp_dir
)
temp_file
=
Tempfile
.
new
(
'trace-tmp-'
,
temp_dir
)
Dir
.
mktmpdir
(
'tmp-trace'
,
temp_dir
)
do
|
dir_path
|
temp_file
&
.
close
temp_path
=
File
.
join
(
dir_path
,
"job.log"
)
yield
(
temp_file
.
path
)
FileUtils
.
copy
(
src_path
,
temp_path
)
ensure
yield
(
temp_path
)
temp_file
&
.
close
end
temp_file
&
.
unlink
end
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment