Skip to content

Commit

Permalink
Improve debug print when tar file extraction fails (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
kerneltime authored Oct 12, 2020
1 parent cd44ded commit df17029
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/apis/minio.min.io/v1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,19 @@ func ExtractTar(filesToExtract []string, basePath, tarFileName string) error {
break
}
}

if err != nil {
return fmt.Errorf("Tar file extraction failed: %w", err)
return fmt.Errorf("Tar file extraction failed for file index: %d, with: %w", success, err)
}
if header.Typeflag == tar.TypeReg {
if name := find(filesToExtract, header.Name); name != "" {
outFile, err := os.OpenFile(basePath+path.Base(name), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0777)
if err != nil {
return fmt.Errorf("Tar file extraction failed: %w", err)
return fmt.Errorf("Tar file extraction failed while opening file: %s, at index: %d, with: %w", name, success, err)
}
if _, err := io.Copy(outFile, tr); err != nil {
_ = outFile.Close()
return fmt.Errorf("Tar file extraction failed: %w", err)
return fmt.Errorf("Tar file extraction failed while copying file: %s, at index: %d, with: %w", name, success, err)
}
_ = outFile.Close()
success--
Expand Down

0 comments on commit df17029

Please sign in to comment.