diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-08-11 09:53:41 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-09-23 10:02:55 +0300 |
commit | 9c4937daf01220a9fd99d67dd5b5d5d9df1e9954 (patch) | |
tree | 6963b82d63c5ba69b429aa9bfe6aa640a7af2af5 | |
parent | 0e459e2167a73235f40f91d747039d7d9f2b0d33 (diff) |
archive: Explicitly ignore error retruned by the tar writer
While we check error codes returned by the tar writer in the general
case when writing an archive, we ignore it in case we have already seen
an error in `TarBuilder.Close()`. We didn't explicitly ignore the error
with a blanket-assignment though, and thus the errcheck linter
complains.
Fix this by assigning the error to the blanket variable and drop the
corresponding exclude from our linting rules.
-rw-r--r-- | .golangci.yml | 1 | ||||
-rw-r--r-- | internal/gitaly/archive/tar_builder.go | 2 |
2 files changed, 1 insertions, 2 deletions
diff --git a/.golangci.yml b/.golangci.yml index 7b874bd4a..a80d3f5fc 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -53,7 +53,6 @@ linters-settings: # eventually fix. exclude-functions: # Close - - (*archive/tar.Writer).Close - (*compress/zlib.Writer).Close - (*database/sql.DB).Close - (*database/sql.Rows).Close diff --git a/internal/gitaly/archive/tar_builder.go b/internal/gitaly/archive/tar_builder.go index 2ae1a0b32..3e93e273e 100644 --- a/internal/gitaly/archive/tar_builder.go +++ b/internal/gitaly/archive/tar_builder.go @@ -196,7 +196,7 @@ func (t *TarBuilder) Close() error { if t.err != nil { // Ignore any close error in favour of reporting the previous one, but // ensure the tar writer is closed to avoid resource leaks - t.tarWriter.Close() + _ = t.tarWriter.Close() return t.err } |