Skip to content

Commit

Permalink
fix: retain share dir
Browse files Browse the repository at this point in the history
  • Loading branch information
aby913 committed Sep 26, 2024
1 parent 575dcad commit 4b4b0ae
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions pkg/storage/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,37 @@ type DeleteTerminusData struct {
}

func (t *DeleteTerminusData) Execute(runtime connector.Runtime) error {
var dirs []string
var terminusDir = "/terminus"
var sharePrefix = fmt.Sprintf("%s/share", terminusDir)
var shareExists bool
filepath.WalkDir(terminusDir, func(path string, d fs.DirEntry, err error) error {
if path != terminusDir {
if !d.IsDir() {
return nil
}

if d.Name() == "share" || strings.HasPrefix(path, sharePrefix) {
shareExists = true
} else {
dirs = append(dirs, path)
return filepath.SkipDir
}
}

return nil
},
)

for _, dir := range dirs {
if err := util.RemoveDir(dir); err != nil {
logger.Errorf("remove %s failed %v", dir, err)
}
}

if util.IsExist("/terminus") {
if err := util.RemoveDir("/terminus"); err != nil {
logger.Errorf("remove %s failed %v", "/terminus", err)
if !shareExists {
if err := util.RemoveDir(terminusDir); err != nil {
logger.Errorf("remove %s failed %v", terminusDir, err)
}
}

Expand Down

0 comments on commit 4b4b0ae

Please sign in to comment.