From 35b0c989f7a33b09a33abf9c7c8f65d08ebdfaa6 Mon Sep 17 00:00:00 2001 From: clsr Date: Tue, 2 Aug 2016 13:16:45 +0200 Subject: Remove maxSize argument from NewStorage --- main.go | 7 ++++--- storage.go | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 23743c4..dae5ccd 100644 --- a/main.go +++ b/main.go @@ -69,12 +69,12 @@ func main() { listenHttps := flag.String("https", "", "address to listen on for HTTPS") cert := flag.String("cert", "", "path to TLS certificate (for HTTPS)") key := flag.String("key", "", "path to TLS key (for HTTPS)") - maxSize := flag.Int64("max-size", 50*1024*1024, "max filesize in bytes") + maxSize := flag.Int64("max-size", DefaultMaxSize, "max filesize in bytes") filterMime := flag.String("filter-mime", "application/x-dosexec,application/x-msdos-program", "comma-separated list of filtered MIME types") filterExt := flag.String("filter-ext", "exe,dll,msi,scr,com,pif", "comma-separated list of filtered file extensions") whitelist := flag.Bool("whitelist", false, "use filter as a whitelist instead of blacklist") grill := flag.Bool("grill", false, "enable grills") - idLength := flag.Int("id-length", 6, "length of uploaded file IDs") + idLength := flag.Int("id-length", DefaultIdLength, "length of uploaded file IDs") idCharset := flag.String("id-charset", "", "charset for uploaded file IDs (default lowercase letters a-z)") flag.Parse() @@ -83,11 +83,12 @@ func main() { initWebsite() - storage = NewStorage("upload", *maxSize) + storage = NewStorage("upload") storage.FilterExt = strings.Split(*filterExt, ",") storage.FilterMime = strings.Split(*filterMime, ",") storage.Whitelist = *whitelist storage.IdLength = *idLength + storage.MaxSize = *maxSize if *idCharset != "" { storage.IdCharset = *idCharset } diff --git a/storage.go b/storage.go index 89f777c..c0e8130 100644 --- a/storage.go +++ b/storage.go @@ -49,7 +49,7 @@ type ErrNotFound struct{ Name string } func (e ErrNotFound) Error() string { return "file " + e.Name + " not found" } -func NewStorage(folder string, maxSize int64) *Storage { +func NewStorage(folder string) *Storage { if err := os.MkdirAll(path.Join(folder, "temp"), 0755); err != nil { panic(err) } @@ -64,7 +64,7 @@ func NewStorage(folder string, maxSize int64) *Storage { Folder: folder, IdCharset: DefaultIdCharset, IdLength: DefaultIdLength, - MaxSize: maxSize, + MaxSize: DefaultMaxSize, } } -- cgit