diff options
author | Stan Hu <stanhu@gmail.com> | 2018-11-27 23:56:40 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-11-27 23:56:40 +0300 |
commit | 6c83c2d8b9305fe67fe31cf944c9d83cdbb00b74 (patch) | |
tree | f127e4af5333c63c2b23a2be6f99c566b4829e58 /lib/gitlab/ci/trace | |
parent | 1524a19302cea096ddf2c008abe1307527ae6938 (diff) | |
parent | 31a1ce2132d83e333e84f365b9aada2e17c61b43 (diff) |
Merge branch 'lock-trace-writes' into 'master'
Lock writes to trace stream
Closes #51502
See merge request gitlab-org/gitlab-ce!23332
Diffstat (limited to 'lib/gitlab/ci/trace')
-rw-r--r-- | lib/gitlab/ci/trace/stream.rb | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/gitlab/ci/trace/stream.rb b/lib/gitlab/ci/trace/stream.rb index bd40fdf59b1..0f23b95ba15 100644 --- a/lib/gitlab/ci/trace/stream.rb +++ b/lib/gitlab/ci/trace/stream.rb @@ -43,19 +43,14 @@ module Gitlab def append(data, offset) data = data.force_encoding(Encoding::BINARY) - stream.truncate(offset) - stream.seek(0, IO::SEEK_END) + stream.seek(offset, IO::SEEK_SET) stream.write(data) + stream.truncate(offset + data.bytesize) stream.flush() end def set(data) - data = data.force_encoding(Encoding::BINARY) - - stream.seek(0, IO::SEEK_SET) - stream.write(data) - stream.truncate(data.bytesize) - stream.flush() + append(data, 0) end def raw(last_lines: nil) |