From 6483240963c455275a6cf636e1e570576463620a Mon Sep 17 00:00:00 2001 From: Hugh Bord Date: Tue, 12 Dec 2023 19:11:48 +0800 Subject: [PATCH] updated .gitignore, improved main.go --- .gitignore | 4 +++- main.go | 13 ++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 7d2cb50..1e3a9af 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -files/ \ No newline at end of file +files/ +dbfile.db +hardfile diff --git a/main.go b/main.go index 0b7639f..65a9b63 100644 --- a/main.go +++ b/main.go @@ -124,9 +124,6 @@ func UploadHandler(w http.ResponseWriter, r *http.Request) { var expiryTime int64 var fileNameLength int - fileNameLength = 0 - expiryTime = 0 - file, _, err := r.FormFile("file") if err != nil { w.WriteHeader(http.StatusBadRequest) @@ -153,10 +150,7 @@ func UploadHandler(w http.ResponseWriter, r *http.Request) { return } } - } - - // Default to conf if not present - if expiryTime == 0 { + } else { expiryTime = int64(conf.FileExpirySeconds) } @@ -172,10 +166,7 @@ func UploadHandler(w http.ResponseWriter, r *http.Request) { return } } - } - - // Default to conf if not present - if fileNameLength == 0 { + } else { fileNameLength = conf.FileLen }