diff options
author | Shinya Maeda <gitlab.shinyamaeda@gmail.com> | 2017-05-06 17:38:56 +0900 |
---|---|---|
committer | Shinya Maeda <gitlab.shinyamaeda@gmail.com> | 2017-05-24 20:10:14 +0900 |
commit | ddf67424ec5d84ff373e5e39195b5012c84eb920 (patch) | |
tree | 9983f0bad167088050b4fdac5a37f80011f87390 /lib | |
parent | 6018afa89fc34b0ea9ba691e3690a9837fadc122 (diff) | |
download | gitlab-ce-ddf67424ec5d84ff373e5e39195b5012c84eb920.tar.gz |
Fix while true
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/trace/stream.rb | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/gitlab/ci/trace/stream.rb b/lib/gitlab/ci/trace/stream.rb index be8e40af016..72a0d669de0 100644 --- a/lib/gitlab/ci/trace/stream.rb +++ b/lib/gitlab/ci/trace/stream.rb @@ -117,23 +117,18 @@ module Gitlab end def reverse_line - pos = 0 + pos = BUFFER_SIZE max = stream.size - while true + while pos < max + stream.seek(-pos, IO::SEEK_END) + yield(stream.read(BUFFER_SIZE)) pos += BUFFER_SIZE - - buf = - if pos <= max - stream.seek(-pos, IO::SEEK_END) - stream.read(BUFFER_SIZE) - else # Reached the head, read only left - stream.seek(0) - stream.read(BUFFER_SIZE - (pos - max)) - end - - yield(buf) end + + # Reached the head, read only left + stream.seek(0) + yield(stream.read(BUFFER_SIZE - (pos - max))) end end end |