From 52928e050724e825643a1eb14da445f398905643 Mon Sep 17 00:00:00 2001 From: Simon Rieger Date: Mon, 2 Sep 2024 15:42:54 +0200 Subject: [PATCH] remove automatic cleanup feature --- go/main.go | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/go/main.go b/go/main.go index c2bc510..68e15c0 100644 --- a/go/main.go +++ b/go/main.go @@ -23,16 +23,7 @@ var ( uploadInterval = 10 * time.Second ) -const ( - uploadDir = "./uploads" - cleanupInterval = 1 * time.Hour - fileLifetime = 48 * time.Hour -) - func main() { - // Starten Sie den Hintergrundprozess zum Löschen alter Dateien - go startCleanupProcess() - http.HandleFunc("/", homeHandler) http.HandleFunc("/upload", uploadHandler) http.HandleFunc("/image/", imageHandler) @@ -45,39 +36,6 @@ func main() { http.ListenAndServe(":8080", nil) } -func startCleanupProcess() { - ticker := time.NewTicker(cleanupInterval) - defer ticker.Stop() - - for { - select { - case <-ticker.C: - cleanupOldFiles() - } - } -} - -func cleanupOldFiles() { - now := time.Now() - err := filepath.Walk(uploadDir, func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - if !info.IsDir() && now.Sub(info.ModTime()) > fileLifetime { - err := os.Remove(path) - if err != nil { - log.Printf("Fehler beim Löschen der Datei %s: %v", path, err) - } else { - log.Printf("Datei gelöscht: %s", path) - } - } - return nil - }) - if err != nil { - log.Printf("Fehler beim Durchsuchen des Verzeichnisses: %v", err) - } -} - func homeHandler(w http.ResponseWriter, r *http.Request) { // Setzen der Content Security Policy w.Header().Set("Content-Security-Policy", "default-src 'self'; script-src 'self'; object-src 'none';")