/*
goredo -- djb's redo implementation on pure Go
-Copyright (C) 2020-2022 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2020-2023 Sergey Matveev <stargrave@stargrave.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
CleanupFull = "full"
CleanupLog = "log"
CleanupTmp = "tmp"
+ CleanupLock = "lock"
)
var DryRun *bool
if err != nil {
return err
}
+ defer dir.Close()
for {
fis, err := dir.Readdir(1 << 10)
if err != nil {
}
}
}
+ case CleanupLock:
+ if strings.HasSuffix(fi.Name(), LockSuffix) {
+ fmt.Println(pth)
+ if !*DryRun {
+ if err = os.Remove(pth); err != nil {
+ return err
+ }
+ }
+ }
case CleanupTmp:
if strings.HasPrefix(fi.Name(), TmpPrefix) {
fmt.Println(pth)
}
}
}
- return dir.Close()
+ return nil
}
func cleanupWalker(root, what string) error {
} else {
err = redoDirClean(pth, what)
}
+ } else if (what == CleanupTmp || what == CleanupFull) &&
+ strings.HasPrefix(fi.Name(), TmpPrefix) {
+ fmt.Println(pthRel)
+ if !*DryRun {
+ err = os.RemoveAll(pth)
+ }
} else {
err = cleanupWalker(pth, what)
}
}
}
}
- return dir.Close()
+ return nil
}