This commit is contained in:
parent
38c05bae6d
commit
a1cc42bdb7
|
|
@ -121,6 +121,10 @@ func DeleteFilesystem() error {
|
||||||
logrus.Info("Deleting filesystem...")
|
logrus.Info("Deleting filesystem...")
|
||||||
return filepath.Walk(constants.RootDir, func(path string, info os.FileInfo, _ error) error {
|
return filepath.Walk(constants.RootDir, func(path string, info os.FileInfo, _ error) error {
|
||||||
if CheckWhitelist(path) {
|
if CheckWhitelist(path) {
|
||||||
|
if ! isExist(path) {
|
||||||
|
logrus.Debugf("Path %s whitelisted, but not exists", path)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
return filepath.SkipDir
|
return filepath.SkipDir
|
||||||
}
|
}
|
||||||
|
|
@ -137,6 +141,13 @@ func DeleteFilesystem() error {
|
||||||
return os.RemoveAll(path)
|
return os.RemoveAll(path)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// isExists returns tru 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
|
// ChildDirInWhitelist returns true if there is a child file or directory of the path in the whitelist
|
||||||
func childDirInWhitelist(path string) bool {
|
func childDirInWhitelist(path string) bool {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue