diff --git a/main.go b/main.go index 6cfbcbc..5c6c4b2 100644 --- a/main.go +++ b/main.go @@ -395,6 +395,9 @@ func cleanupProcedure(duration time.Duration, dryRun bool) { if !d.IsDir() { return nil } + if filepath.Clean(path) == filepath.Clean(uploadDir) { + return nil + } empty, err := isDirEmpty(path) if empty { emptyDirs = append(emptyDirs, path) @@ -406,6 +409,8 @@ func cleanupProcedure(duration time.Duration, dryRun bool) { } for { + oldFiles = oldFiles[:0] + emptyDirs = emptyDirs[:0] filepath.WalkDir(uploadDir, deleteIfTooOld) for _, file := range oldFiles {