From 2a97dccd8f5b036d701a5577367deb1f16385c3d Mon Sep 17 00:00:00 2001 From: Zhijie Yang Date: Wed, 27 Nov 2024 22:32:24 +0100 Subject: [PATCH] chore: use defer and add comments --- internal/deb/extract.go | 4 ++-- internal/fsutil/create.go | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/deb/extract.go b/internal/deb/extract.go index 81a16062..b0960869 100644 --- a/internal/deb/extract.go +++ b/internal/deb/extract.go @@ -133,6 +133,8 @@ func getDataReader(pkgReader io.ReadSeeker) (io.ReadCloser, error) { func extractData(pkgReader io.ReadSeeker, options *ExtractOptions) error { dataReader, err := getDataReader(pkgReader) + defer dataReader.Close() + if err != nil { return err } @@ -338,8 +340,6 @@ func extractData(pkgReader io.ReadSeeker, options *ExtractOptions) error { } } - dataReader.Close() - return nil } diff --git a/internal/fsutil/create.go b/internal/fsutil/create.go index 319a26ee..6b54e524 100644 --- a/internal/fsutil/create.go +++ b/internal/fsutil/create.go @@ -77,6 +77,7 @@ func Create(options *CreateOptions) (*Entry, error) { return nil, err } mode := s.Mode() + // Overrides mode if the entry is not a link and the mode differs. if o.OverrideMode && mode != o.Mode && o.Link == "" { err := os.Chmod(o.Path, o.Mode) if err != nil {