Fix cleanup routine to reset state each cycle and skip removing upload root
This commit is contained in:
@@ -395,6 +395,9 @@ func cleanupProcedure(duration time.Duration, dryRun bool) {
|
|||||||
if !d.IsDir() {
|
if !d.IsDir() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if filepath.Clean(path) == filepath.Clean(uploadDir) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
empty, err := isDirEmpty(path)
|
empty, err := isDirEmpty(path)
|
||||||
if empty {
|
if empty {
|
||||||
emptyDirs = append(emptyDirs, path)
|
emptyDirs = append(emptyDirs, path)
|
||||||
@@ -406,6 +409,8 @@ func cleanupProcedure(duration time.Duration, dryRun bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
oldFiles = oldFiles[:0]
|
||||||
|
emptyDirs = emptyDirs[:0]
|
||||||
|
|
||||||
filepath.WalkDir(uploadDir, deleteIfTooOld)
|
filepath.WalkDir(uploadDir, deleteIfTooOld)
|
||||||
for _, file := range oldFiles {
|
for _, file := range oldFiles {
|
||||||
|
|||||||
Reference in New Issue
Block a user