diff options
author | Stan Hu <stanhu@gmail.com> | 2018-10-18 17:01:55 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-10-18 23:15:24 -0700 |
commit | 4c4d1b792867195920fb6d6fb41cfa03a99cd299 (patch) | |
tree | bf5124452dc3de0871d22e931f4ab6466942e2a2 | |
parent | 5edf87d0ac699575421ec96cbc0fc91ea0c3c078 (diff) | |
download | gitlab-ce-4c4d1b792867195920fb6d6fb41cfa03a99cd299.tar.gz |
Fix EOF detection with CI artifacts metadata
There are some corner cases where a perfectly correct GZIP stream may
not hit the EOF until another read is attempted. We now skip the entry
if we don't see any valid data, which allows the EOF check to work
properly.
Closes https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22479
-rw-r--r-- | changelogs/unreleased/sh-pages-eof-error.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/ci/build/artifacts/metadata.rb | 7 |
2 files changed, 10 insertions, 2 deletions
diff --git a/changelogs/unreleased/sh-pages-eof-error.yml b/changelogs/unreleased/sh-pages-eof-error.yml new file mode 100644 index 00000000000..497a74c1458 --- /dev/null +++ b/changelogs/unreleased/sh-pages-eof-error.yml @@ -0,0 +1,5 @@ +--- +title: Fix EOF detection with CI artifacts metadata +merge_request: 22479 +author: +type: fixed diff --git a/lib/gitlab/ci/build/artifacts/metadata.rb b/lib/gitlab/ci/build/artifacts/metadata.rb index 375d8bc1ff5..551d4f4473e 100644 --- a/lib/gitlab/ci/build/artifacts/metadata.rb +++ b/lib/gitlab/ci/build/artifacts/metadata.rb @@ -59,9 +59,12 @@ module Gitlab until gz.eof? begin - path = read_string(gz).force_encoding('UTF-8') - meta = read_string(gz).force_encoding('UTF-8') + path = read_string(gz)&.force_encoding('UTF-8') + meta = read_string(gz)&.force_encoding('UTF-8') + # We might hit an EOF while reading either value, so we should + # abort if we don't get any data. + next unless path && meta next unless path.valid_encoding? && meta.valid_encoding? next unless path =~ match_pattern next if path =~ INVALID_PATH_PATTERN |