More work on file storage
Some checks failed
/ docker (push) Failing after 1m48s

This commit is contained in:
Melody Becker 2025-06-16 17:01:15 +02:00
parent 8e6f814ba4
commit e317da1b66
Signed by: mstar
SSH key fingerprint: SHA256:9VAo09aaVNTWKzPW7Hq2LW+ox9OdwmTSHRoD4mlz1yI
6 changed files with 106 additions and 18 deletions

View file

@ -3,6 +3,7 @@ package config
import (
"fmt"
"os"
"path"
"strings"
"git.mstar.dev/mstar/goutils/other"
@ -73,6 +74,13 @@ type ConfigStorage struct {
MaxReconnectAttempts int `toml:"max_reconnect_attempts"`
}
type ConfigTranscoder struct {
SharedDirectory string `toml:"shared_directory"`
Secret string `toml:"secret"`
ServerAddress string `toml:"server_address"`
ServerPort int `toml:"server_port"`
}
type ConfigS3 struct {
KeyId string `toml:"key_id"`
Secret string `toml:"secret"`
@ -143,6 +151,7 @@ type Config struct {
Admin ConfigAdmin `toml:"admin"`
Webauthn ConfigWebAuthn `toml:"webauthn"`
Storage ConfigStorage `toml:"storage"`
Transcoder ConfigTranscoder `toml:"transcoder"`
Mail ConfigMail `toml:"mail"`
Self ConfigSelf `toml:"self"`
S3 ConfigS3 `toml:"s3"`
@ -185,13 +194,15 @@ var defaultConfig Config = Config{
Port: 5432,
SslMode: other.IntoPointer("disable"),
TimeZone: other.IntoPointer("Europe/Berlin"),
RedisUrl: nil,
MaxInMemoryCacheSize: 1e6, // 1 Megabyte
MaxInMemoryCacheTTL: 5,
MaxRedisCacheTTL: nil,
EncryptionKey: "Encryption key for sensitive information. DO NOT CHANGE THIS AFTER SETUP",
MaxReconnectAttempts: 3,
},
Transcoder: ConfigTranscoder{
SharedDirectory: "/tmp/linstrom-transcoder",
Secret: "The same secret as configured in the transcoder",
ServerAddress: "127.0.0.1",
ServerPort: 5594,
},
Mail: ConfigMail{
Host: "localhost",
Port: 587,
@ -275,6 +286,18 @@ func (sc *ConfigStorage) BuildPostgresDSN() string {
return dsn
}
func (tc *ConfigTranscoder) Address() string {
return fmt.Sprintf("%s:%d", tc.ServerAddress, tc.ServerPort)
}
func (tc *ConfigTranscoder) InDir() string {
return path.Join(tc.SharedDirectory, "input")
}
func (tc *ConfigTranscoder) OutDir() string {
return path.Join(tc.SharedDirectory, "output")
}
func WriteDefaultConfig(toFile string) error {
log.Trace().Caller().Send()
log.Info().Str("config-file", toFile).Msg("Writing default config to file")