implement expiry!!!

oh my fucking GOD bro, i've seen expiry SO SO SO much it idek if i've been spelling it right at this point, please let me be done with this
This commit is contained in:
2026-11-10 22:15:20 -05:00
parent 3a336b79c8
commit 9bda8bc93d
3 changed files with 110 additions and 0 deletions
+12
View File
@@ -14,6 +14,7 @@ type Config struct {
UploadDir string
MaxPasteBytes int64
MaxFileBytes int64
Expiries []Expiry
DatabasePath string
}
@@ -45,10 +46,21 @@ func loadConfig() (Config, error) {
databasePath := envOrDefault("MINIBIN_DATABASE_PATH", "minibin.sqlite")
expiriesSetting := envOrDefault("MINIBIN_EXPIRIES", "1h,12h,1d,7d,2w,1mo,6mo,1y,5y, 0")
var expiries []Expiry
for entry := range strings.SplitSeq(expiriesSetting, ",") {
expiry, err := parseExpiry(entry)
if err != nil {
return Config{}, fmt.Errorf("MINIBIN_EXPIRIES: %w", err)
}
expiries = append(expiries, expiry)
}
return Config{
UploadDir: uploadDir,
MaxPasteBytes: maxPasteKiB * 1024,
MaxFileBytes: maxFileKiB * 1024,
Expiries: expiries,
DatabasePath: databasePath,
}, nil