summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/ci/trace.rb4
-rw-r--r--lib/gitlab/ci/trace/chunked_io.rb3
-rw-r--r--lib/gitlab/ci/trace/stream.rb8
3 files changed, 9 insertions, 6 deletions
diff --git a/lib/gitlab/ci/trace.rb b/lib/gitlab/ci/trace.rb
index 6554c924e5c..e4f924d2fe4 100644
--- a/lib/gitlab/ci/trace.rb
+++ b/lib/gitlab/ci/trace.rb
@@ -43,7 +43,7 @@ module Gitlab
end
def append(data, offset)
- write do |stream|
+ write('a+b') do |stream|
current_length = stream.size
return -current_length unless current_length == offset
@@ -75,7 +75,7 @@ module Gitlab
stream&.close
end
- def write(mode = 'a+b')
+ def write(mode)
stream = Gitlab::Ci::Trace::Stream.new do
if current_path
File.open(current_path, mode)
diff --git a/lib/gitlab/ci/trace/chunked_io.rb b/lib/gitlab/ci/trace/chunked_io.rb
index 2caebe3c95e..6b4a9f61961 100644
--- a/lib/gitlab/ci/trace/chunked_io.rb
+++ b/lib/gitlab/ci/trace/chunked_io.rb
@@ -114,7 +114,6 @@ module Gitlab
def write(data)
start_pos = tell
- data = data.force_encoding(Encoding::BINARY)
while tell < start_pos + data.bytesize
# get slice from current offset till the end where it falls into chunk
@@ -178,7 +177,7 @@ module Gitlab
current_chunk.tap do |chunk|
raise FailedToGetChunkError unless chunk
- @chunk = chunk.data.force_encoding(Encoding::BINARY)
+ @chunk = chunk.data
@chunk_range = chunk.range
end
end
diff --git a/lib/gitlab/ci/trace/stream.rb b/lib/gitlab/ci/trace/stream.rb
index bcdd4225ce7..e78bca4be99 100644
--- a/lib/gitlab/ci/trace/stream.rb
+++ b/lib/gitlab/ci/trace/stream.rb
@@ -37,6 +37,8 @@ module Gitlab
end
def append(data, offset)
+ data = data.force_encoding(Encoding::BINARY)
+
stream.truncate(offset)
stream.seek(0, IO::SEEK_END)
stream.write(data)
@@ -44,6 +46,8 @@ module Gitlab
end
def set(data)
+ data = data.force_encoding(Encoding::BINARY)
+
stream.seek(0, IO::SEEK_SET)
stream.write(data)
stream.truncate(data.bytesize)
@@ -126,11 +130,11 @@ module Gitlab
buf += debris
debris, *lines = buf.each_line.to_a
lines.reverse_each do |line|
- yield(line.force_encoding('UTF-8'))
+ yield(line.force_encoding(Encoding.default_external))
end
end
- yield(debris.force_encoding('UTF-8')) unless debris.empty?
+ yield(debris.force_encoding(Encoding.default_external)) unless debris.empty?
end
def read_backward(length)