Skip to content

Commit f9cdf1c

Browse files
ilopezlunaCopilot
andauthored
Update pkg/distribution/packaging/dirtar.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent eea47c1 commit f9cdf1c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/distribution/packaging/dirtar.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,16 @@ func CreateDirectoryTarArchive(dirPath string) (string, error) {
7979
if err != nil {
8080
return fmt.Errorf("open file %s: %w", path, err)
8181
}
82-
defer file.Close()
82+
8383

8484
// Copy file contents
8585
if _, err := io.Copy(tw, file); err != nil {
86+
file.Close()
8687
return fmt.Errorf("write tar content for %s: %w", path, err)
8788
}
89+
if err := file.Close(); err != nil {
90+
return fmt.Errorf("close file %s: %w", path, err)
91+
}
8892
}
8993

9094
return nil

0 commit comments

Comments
 (0)