Saved 2 lines by deferring each of two calls instead of wrapping in an anonymous func.
Also, removed old cURL handling in an Upload handler.
This commit is contained in:
parent
345869608e
commit
9a889e746a
@ -74,10 +74,8 @@ func (h *UploadHandlers) Upload(w http.ResponseWriter, r *http.Request) {
|
||||
Error(w, r, http.StatusInternalServerError, "Error reading an incoming file.")
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
os.Remove(fHandler.Filename)
|
||||
f.Close()
|
||||
}()
|
||||
defer os.Remove(fHandler.Filename)
|
||||
defer f.Close()
|
||||
|
||||
var leftSpace int64 = storCapacity - *h.uploadDirSize
|
||||
|
||||
@ -148,13 +146,8 @@ func (h *UploadHandlers) Upload(w http.ResponseWriter, r *http.Request) {
|
||||
_, scheme := utils.NetworkType(r.Host)
|
||||
site := scheme + "://" + r.Host
|
||||
|
||||
if strings.Contains(r.UserAgent(), "curl") {
|
||||
w.Write([]byte(site + downloadURLParsed.String() + "\r\n"))
|
||||
return
|
||||
}
|
||||
|
||||
if strings.Contains(r.UserAgent(), "curl") || strings.Contains(r.UserAgent(), "Wget") {
|
||||
fmt.Fprintln(w, downloadURLParsed.String(), "will be kept for", h.keepForHours)
|
||||
fmt.Fprintln(w, site+downloadURLParsed.String(), "will be kept for", h.keepForHours)
|
||||
} else {
|
||||
web.Uploaded(utils.MainSite(r.Host), site, downloadURLParsed.String(), h.keepForHours, w)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user