fix: root path name on archive
This commit is contained in:
parent
488d98045e
commit
426b38bb33
19
http/raw.go
19
http/raw.go
|
@ -173,13 +173,6 @@ func rawDirHandler(w http.ResponseWriter, r *http.Request, d *data, file *files.
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
|
||||||
name := file.Name
|
|
||||||
if name == "." || name == "" {
|
|
||||||
name = "archive"
|
|
||||||
}
|
|
||||||
name += extension
|
|
||||||
w.Header().Set("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(name))
|
|
||||||
|
|
||||||
err = ar.Create(w)
|
err = ar.Create(w)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
|
@ -188,6 +181,18 @@ func rawDirHandler(w http.ResponseWriter, r *http.Request, d *data, file *files.
|
||||||
|
|
||||||
commonDir := fileutils.CommonPrefix(filepath.Separator, filenames...)
|
commonDir := fileutils.CommonPrefix(filepath.Separator, filenames...)
|
||||||
|
|
||||||
|
var name string
|
||||||
|
if len(filenames) > 1 {
|
||||||
|
name = "_" + filepath.Base(commonDir)
|
||||||
|
} else {
|
||||||
|
name = file.Name
|
||||||
|
}
|
||||||
|
if name == "." || name == "" {
|
||||||
|
name = "archive"
|
||||||
|
}
|
||||||
|
name += extension
|
||||||
|
w.Header().Set("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(name))
|
||||||
|
|
||||||
for _, fname := range filenames {
|
for _, fname := range filenames {
|
||||||
err = addFile(ar, d, fname, commonDir)
|
err = addFile(ar, d, fname, commonDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue