Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit 753dc64

Browse files
author
Priya Wadhwa
committed
Added log
1 parent 7c42974 commit 753dc64

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

pkg/util/tar_utils.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func unpackTar(tr *tar.Reader, path string, whitelist []string) error {
4747

4848
// Remove the whited-out path.
4949
newName := strings.Replace(rmPath, ".wh.", "", 1)
50-
if err = walkAndRemove(newName); err != nil {
50+
if err = os.RemoveAll(newName); err != nil {
5151
logrus.Error(err)
5252
}
5353
continue
@@ -111,7 +111,7 @@ func unpackTar(tr *tar.Reader, path string, whitelist []string) error {
111111
// Explicitly delete an existing file before continuing.
112112
if _, err := os.Stat(target); !os.IsNotExist(err) {
113113
logrus.Debugf("Removing %s to create symlink.", target)
114-
if err := walkAndRemove(target); err != nil {
114+
if err := os.RemoveAll(target); err != nil {
115115
logrus.Debugf("Unable to remove %s: %s", target, err)
116116
}
117117
}
@@ -124,19 +124,10 @@ func unpackTar(tr *tar.Reader, path string, whitelist []string) error {
124124
return nil
125125
}
126126

127-
func walkAndRemove(p string) error {
128-
return filepath.Walk(p, func(path string, info os.FileInfo, err error) error {
129-
if e := os.Chmod(path, 0777); e != nil {
130-
logrus.Errorf("Error updating file permissions on %s before removing for symlink creation", path)
131-
return e
132-
}
133-
return os.RemoveAll(path)
134-
})
135-
}
136-
137127
func checkWhitelist(target string, whitelist []string) bool {
138128
for _, w := range whitelist {
139129
if HasFilepathPrefix(target, w) {
130+
logrus.Debugf("Not extracting %s, as it has prefix %s which is whitelisted", target, w)
140131
return true
141132
}
142133
}

0 commit comments

Comments
 (0)