all repos — honk @ 9e28eae7b416d8836d54a3040cb1d06fe8aa4fa3

my fork of honk

cleanup command to collect database garbage
Ted Unangst tedu@tedunangst.com
Tue, 21 May 2019 14:06:17 -0400
commit

9e28eae7b416d8836d54a3040cb1d06fe8aa4fa3

parent

5dd5cc5102fcbbd7dba985ce2339e96240b34013

3 files changed, 14 insertions(+), 0 deletions(-)

jump to
M docs/manual.txtdocs/manual.txt

@@ -59,6 +59,12 @@ Custom emus may be provided by creating and populating the emus directory.

emus may be referenced when composing a honk via colon wrapping. How pleasant. This :example: will be replaced by emus/example.png. +-- cleanup + +One may occasionally run `honk cleanup` to free up internal space in the +database. (This does not run vacuum, so the file size will not immediately +shrink.) + -- proxy honk requires a TLS terminating reverse proxy be configured. It communicates
M honk.gohonk.go

@@ -1302,6 +1302,11 @@ log.Fatal(err)

} } +func cleanupdb() { + db := opendatabase() + doordie(db, "delete from files where fileid not in (select fileid from donks)") +} + var stmtHonkers, stmtDubbers, stmtSaveHonker, stmtUpdateFlavor, stmtUpdateCombos *sql.Stmt var stmtOneXonk, stmtPublicHonks, stmtUserHonks, stmtHonksByCombo, stmtHonksByConvoy *sql.Stmt var stmtHonksForUser, stmtHonksForMe, stmtSaveDub *sql.Stmt

@@ -1403,6 +1408,8 @@ }

getconfig("servername", &serverName) prepareStatements(db) switch cmd { + case "cleanup": + cleanupdb() case "ping": if len(os.Args) < 4 { fmt.Printf("usage: honk ping from to\n")
M upgradedb.goupgradedb.go

@@ -92,5 +92,6 @@ case 8:

default: log.Fatalf("can't upgrade unknown version %d", dbversion) } + cleanupdb() os.Exit(0) }