From 6b5bf4ced13857a3a3d5ee805482005dc61b37fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ken-H=C3=A5vard=20Lieng?= Date: Sun, 17 May 2020 02:14:35 +0200 Subject: [PATCH] Add per-user download directory --- config.default.toml | 1 - config/config.go | 3 +-- server/irc.go | 2 +- storage/directory.go | 4 ++++ 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/config.default.toml b/config.default.toml index 20e3f620..cfe5b29b 100644 --- a/config.default.toml +++ b/config.default.toml @@ -5,7 +5,6 @@ port = 80 hexIP = false verify_certificates = true -download_folder = "" autoget = false # Defaults for the client connect form diff --git a/config/config.go b/config/config.go index 72515fa3..7bc67f99 100644 --- a/config/config.go +++ b/config/config.go @@ -13,8 +13,7 @@ type Config struct { Port string Dev bool HexIP bool - VerifyCertificates bool `mapstructure:"verify_certificates"` - DownloadFolder string `mapstructure:"download_folder"` + VerifyCertificates bool `mapstructure:"verify_certificates"` Autoget bool Headers map[string]string Defaults Defaults diff --git a/server/irc.go b/server/irc.go index f708e9d6..23336a64 100644 --- a/server/irc.go +++ b/server/irc.go @@ -70,7 +70,7 @@ func connectIRC(server *storage.Server, state *State, srcIP []byte) *irc.Client } } - i.DownloadFolder = cfg.DownloadFolder + i.DownloadFolder = storage.Path.Downloads(state.user.Username) i.Autoget = cfg.Autoget state.setIRC(server.Host, i) diff --git a/storage/directory.go b/storage/directory.go index 0aced016..55ad3272 100644 --- a/storage/directory.go +++ b/storage/directory.go @@ -52,6 +52,10 @@ func (d directory) Key(username string) string { return filepath.Join(d.User(username), "key.pem") } +func (d directory) Downloads(username string) string { + return filepath.Join(d.User(username), "downloads") +} + func (d directory) Config() string { return filepath.Join(d.ConfigRoot(), "config.toml") }