Made spent cleanups run on the correct database and make them show how many rows where deleted

This commit is contained in:
Tracker-Friendly 2024-07-21 09:49:55 +01:00
parent ef54b67803
commit 6ac1c27db5
1 changed files with 8 additions and 1 deletions

View File

@ -1440,9 +1440,16 @@ func main() {
go func() {
for {
time.Sleep(time.Minute)
_, err := conn.Exec("DELETE FROM spent WHERE expires < ?", time.Now().Unix())
affected, err := mem.Exec("DELETE FROM spent WHERE expires < ?", time.Now().Unix())
if err != nil {
log.Println("[ERROR] Unknown in spent cleanup Exec():", err)
} else {
affectedRows, err := affected.RowsAffected()
if err != nil {
log.Println("[ERROR] Unknown in spent cleanup RowsAffected():", err)
} else {
log.Println("[INFO] Spent cleanup complete, deleted "+strconv.FormatInt(affectedRows, 10)+" rows at", time.Now().Unix())
}
}
}
}()