Skip to content

Commit

Permalink
Merge pull request GoogleContainerTools#765 from Onlinehead/fix/files…
Browse files Browse the repository at this point in the history
…ystem-delete-fix

Fix SIGSEGV on file system deletion while building
  • Loading branch information
jonjohnsonjr authored Sep 25, 2019
2 parents afb9c5b + a21129f commit 51734fc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/util/fs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ func DeleteFilesystem() error {
logrus.Info("Deleting filesystem...")
return filepath.Walk(constants.RootDir, func(path string, info os.FileInfo, _ error) error {
if CheckWhitelist(path) {
if !isExist(path) {
logrus.Debugf("Path %s whitelisted, but not exists", path)
return nil
}
if info.IsDir() {
return filepath.SkipDir
}
Expand All @@ -138,6 +142,14 @@ func DeleteFilesystem() error {
})
}

// isExists returns true if path exists
func isExist(path string) bool {
if _, err := os.Stat(path); err == nil {
return true
}
return false
}

// ChildDirInWhitelist returns true if there is a child file or directory of the path in the whitelist
func childDirInWhitelist(path string) bool {
for _, d := range whitelist {
Expand Down

0 comments on commit 51734fc

Please sign in to comment.