1
0

A micro-optimisation. We don't need a name parameter if there is no such file anyway.

This commit is contained in:
Alexander Andreev 2022-03-29 18:41:05 +04:00
parent 6189ddd48d
commit b49f863abf
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F

View File

@ -212,7 +212,6 @@ func (h *UploadHandlers) Upload(w http.ResponseWriter, r *http.Request) {
func (h *UploadHandlers) Download(w http.ResponseWriter, r *http.Request) {
saltedHash := server.GetURLParam(r, "hash")
name := server.GetURLParam(r, "name")
path := path.Join(h.conf.Uploads.Directory, saltedHash)
@ -222,6 +221,8 @@ func (h *UploadHandlers) Download(w http.ResponseWriter, r *http.Request) {
return
}
name := server.GetURLParam(r, "name")
w.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", name))
fd, err := os.Open(path)