Delete files as part of delete user command
alex wennerberg alex@alexwennerberg.com
Sat, 31 Oct 2020 09:26:27 -0700
2 files changed,
4 insertions(+),
2 deletions(-)
M
admin.go
→
admin.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.toml
→
example-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