feat: cleanup files older than 1 day
This commit is contained in:
parent
b933d6ab40
commit
330f38289a
1 changed files with 11 additions and 0 deletions
|
@ -392,6 +392,7 @@ func startCleanupScheduler() {
|
||||||
go func() {
|
go func() {
|
||||||
for range ticker.C {
|
for range ticker.C {
|
||||||
cleanupChunks()
|
cleanupChunks()
|
||||||
|
cleanupOldFiles()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -405,3 +406,13 @@ func cleanupChunks() {
|
||||||
fmt.Printf("error cleaning up chunks: %v\n", err)
|
fmt.Printf("error cleaning up chunks: %v\n", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cleanupOldFiles() {
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
_, err := db.ExecContext(ctx, "DELETE FROM files WHERE created_at < NOW() - INTERVAL '1 day'")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("error cleaning up old files: %v\n", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue