From 5fcd2b447360b9e430f20e8befa139390863ff89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Sat, 29 Aug 2026 00:42:23 +0200 Subject: [PATCH] Fix cleanup routine to reset state each cycle and skip removing upload root --- main.go | 5 +++++ 1 file changed, 5 insertions(+) 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 {