From 9c265b9f14130cd9ef9d3b1e368a6593cd0ad2de Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Fri, 31 May 2019 03:43:08 -0400 Subject: [PATCH] faster and simpler cleanup by deleting everything older than 30 days --- honk.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/honk.go b/honk.go index 5940e67..48e459a 100644 --- a/honk.go +++ b/honk.go @@ -1335,7 +1335,8 @@ func cleanupdb() { } } expdate := time.Now().UTC().Add(-30 * 24 * time.Hour).Format(dbtimeformat) - doordie(db, "update files set content = '', local = 0 where length(content) > 20000 and fileid in (select fileid from donks join honks on donks.honkid = honks.honkid where honks.dt < ? and whofore = 0) and fileid not in (select fileid from donks join honks on donks.honkid = honks.honkid where whofore = 2 or whofore = 3)", expdate) + doordie(db, "delete from donks where honkid in (select honkid from honks where dt < ? and whofore = 0)", expdate) + doordie(db, "delete from honks where dt < ? and whofore = 0", expdate) doordie(db, "delete from files where fileid not in (select fileid from donks)") }