Skip to content

Commit

Permalink
fix: skip unreadable files
Browse files Browse the repository at this point in the history
  • Loading branch information
aiexz committed Feb 17, 2024
1 parent ea97444 commit b8ca503
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions internal/compress/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ import (
func CompressPath(targetPath string, buf io.Writer) error {
// check if targetPath is directory
_, err := os.Stat(targetPath)
//get parent directory of targetPath
baseDir := path.Dir(targetPath)

if err != nil {
return err
}
//get parent directory of targetPath
baseDir := path.Dir(targetPath)
// taken from https://gist.github.com/mimoo/25fc9716e0f1353791f5908f94d6e726
zr := gzip.NewWriter(buf)
tw := tar.NewWriter(zr)
Expand All @@ -31,6 +30,11 @@ func CompressPath(targetPath string, buf io.Writer) error {
return err
}

if header.Mode&0400 == 0 {
fmt.Println("Skipping file", file, "as it is not readable")
return nil
}

relPath, err := filepath.Rel(baseDir, file)
if err != nil {
fmt.Println(err)
Expand Down

0 comments on commit b8ca503

Please sign in to comment.