all repos — flounder @ 383d618d53b72f3ca8aec4643ca60e7a1695f685

A small site builder for the Gemini protocol

Delete files as part of delete user command
alex wennerberg alex@alexwennerberg.com
Sat, 31 Oct 2020 09:26:27 -0700
commit

383d618d53b72f3ca8aec4643ca60e7a1695f685

parent

e8808331dd91745dcbae79724164de0d04bd18a3

2 files changed, 4 insertions(+), 2 deletions(-)

jump to
M admin.goadmin.go

@@ -28,6 +28,7 @@ err := activateUser(username)

log.Fatal(err) case "delete-user": username := os.Args[3] + // TODO add confirmation err := deleteUser(username) log.Fatal(err) }

@@ -59,10 +60,11 @@ return nil

} func deleteUser(username string) error { - // not sure whether we should delete files too _, err := DB.Exec("DELETE FROM user WHERE username = $1", username) if err != nil { return err } + username = filepath.Clean(username) + os.RemoveAll(path.Join(c.FilesDirectory, username)) return nil }
M example-config.tomlexample-config.toml

@@ -13,7 +13,7 @@ FilesDirectory="./files"

LogFile="./flounder.log" # Gemini autogenerates self-signed certs -GeminiCertStore="./" +GeminiCertStore="/tmp" # A wildcard TLS cert for HTTPS. # Only required if HttpsEnabled=true