consistency
Former-commit-id: f0de208a4ae4cd0df9056443fe7a6a823882eca2 [formerly 3c65bde6f2dede145eca8f0d7c10a4d8124a01ef] [formerly 97100fe7d36d445babbc13a669d9c75577cb02d7 [formerly 6e04c97bb9d3e689e583f347588740d2d214e62b]] Former-commit-id: 30f9afb795307f67cd9bccd2f35742a21ee69fde [formerly bc8a04744ca91ad2f951f0888cc11b023d6a067a] Former-commit-id: 7397ffff5d09a3a56b29f7119d696ab4a4507893
This commit is contained in:
14
download.go
14
download.go
@@ -14,12 +14,12 @@ import (
|
||||
|
||||
// download creates an archive in one of the supported formats (zip, tar,
|
||||
// tar.gz or tar.bz2) and sends it to be downloaded.
|
||||
func download(ctx *requestContext, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
func download(c *requestContext, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||
query := r.URL.Query().Get("download")
|
||||
|
||||
if !ctx.Info.IsDir {
|
||||
w.Header().Set("Content-Disposition", "attachment; filename="+ctx.Info.Name)
|
||||
http.ServeFile(w, r, ctx.Info.Path)
|
||||
if !c.fi.IsDir {
|
||||
w.Header().Set("Content-Disposition", "attachment; filename="+c.fi.Name)
|
||||
http.ServeFile(w, r, c.fi.Path)
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
@@ -34,11 +34,11 @@ func download(ctx *requestContext, w http.ResponseWriter, r *http.Request) (int,
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
files = append(files, filepath.Join(ctx.Info.Path, name))
|
||||
files = append(files, filepath.Join(c.fi.Path, name))
|
||||
}
|
||||
|
||||
} else {
|
||||
files = append(files, ctx.Info.Path)
|
||||
files = append(files, c.fi.Path)
|
||||
}
|
||||
|
||||
if query == "true" {
|
||||
@@ -84,7 +84,7 @@ func download(ctx *requestContext, w http.ResponseWriter, r *http.Request) (int,
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
name := ctx.Info.Name
|
||||
name := c.fi.Name
|
||||
if name == "." || name == "" {
|
||||
name = "download"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user