Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-08-11 14:27:08 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-09-23 10:02:55 +0300
commit5cccaa21826849eb3b57a32325e9cc3ec19c5e40 (patch)
treeddb3f337d662bbed120bd0232882664be6add751
parent72b71fc5579eb9930566bcfc2df9f0dbe13e25b6 (diff)
packed_binaries: Check error code when closing packed file
We don't properly verify the error code when closing the file that corresponds to the packed binary. While this doesn't really matter in the first place, fixing this one case lets us drop another exception to our linting rules.
-rw-r--r--.golangci.yml1
-rw-r--r--packed_binaries.go14
2 files changed, 12 insertions, 3 deletions
diff --git a/.golangci.yml b/.golangci.yml
index 17cad66ec..f97d22a09 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -64,7 +64,6 @@ linters-settings:
- (*io.PipeWriter).Close
- (*os.File).Close
- (io.Closer).Close
- - (io/fs.File).Close
- (net.Conn).Close
- (net.Listener).Close
forbidigo:
diff --git a/packed_binaries.go b/packed_binaries.go
index fe3e435e0..6b0774988 100644
--- a/packed_binaries.go
+++ b/packed_binaries.go
@@ -40,14 +40,20 @@ func UnpackAuxiliaryBinaries(destinationDir string) error {
if err != nil {
return fmt.Errorf("open packed binary %q: %w", packedPath, err)
}
- defer packedFile.Close()
+ defer func() {
+ // We already check the error below.
+ _ = packedFile.Close()
+ }()
unpackedPath := filepath.Join(destinationDir, entry.Name())
unpackedFile, err := os.OpenFile(unpackedPath, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o700)
if err != nil {
return err
}
- defer unpackedFile.Close()
+ defer func() {
+ // We already check the error below.
+ _ = unpackedFile.Close()
+ }()
if _, err := io.Copy(unpackedFile, packedFile); err != nil {
return fmt.Errorf("unpack %q: %w", unpackedPath, err)
@@ -57,6 +63,10 @@ func UnpackAuxiliaryBinaries(destinationDir string) error {
return fmt.Errorf("close %q: %w", unpackedPath, err)
}
+ if err := packedFile.Close(); err != nil {
+ return fmt.Errorf("close packed file %q: %w", packedPath, err)
+ }
+
return nil
}(); err != nil {
return err