updated .gitignore, improved main.go

This commit is contained in:
Hugh Bord 2023-12-12 19:11:48 +08:00
parent b8c2940be6
commit 6483240963
2 changed files with 5 additions and 12 deletions

4
.gitignore vendored
View File

@ -1 +1,3 @@
files/ files/
dbfile.db
hardfile

13
main.go
View File

@ -124,9 +124,6 @@ func UploadHandler(w http.ResponseWriter, r *http.Request) {
var expiryTime int64 var expiryTime int64
var fileNameLength int var fileNameLength int
fileNameLength = 0
expiryTime = 0
file, _, err := r.FormFile("file") file, _, err := r.FormFile("file")
if err != nil { if err != nil {
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
@ -153,10 +150,7 @@ func UploadHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
} }
} } else {
// Default to conf if not present
if expiryTime == 0 {
expiryTime = int64(conf.FileExpirySeconds) expiryTime = int64(conf.FileExpirySeconds)
} }
@ -172,10 +166,7 @@ func UploadHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
} }
} } else {
// Default to conf if not present
if fileNameLength == 0 {
fileNameLength = conf.FileLen fileNameLength = conf.FileLen
} }