fix: root path name on archive

This commit is contained in:
Ramires Viana 2021-03-12 15:52:52 +00:00
parent 488d98045e
commit 426b38bb33
1 changed files with 12 additions and 7 deletions

View File

@ -173,13 +173,6 @@ func rawDirHandler(w http.ResponseWriter, r *http.Request, d *data, file *files.
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)
if err != nil {
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...)
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 {
err = addFile(ar, d, fname, commonDir)
if err != nil {