fix: empty archive name on directory download

pull/1353/head
Ramires Viana 2021-03-26 14:45:18 +00:00
parent 59f9964e80
commit 2697093ac1
1 changed files with 6 additions and 6 deletions

View File

@ -181,14 +181,14 @@ 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 name := filepath.Base(commonDir)
if len(filenames) > 1 { if name == "." || name == "" || name == string(filepath.Separator) {
name = "_" + filepath.Base(commonDir)
} else {
name = file.Name name = file.Name
} }
if name == "." || name == "" { // Prefix used to distinguish a filelist generated
name = "archive" // archive from the full directory archive
if len(filenames) > 1 {
name = "_" + name
} }
name += extension name += extension
w.Header().Set("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(name)) w.Header().Set("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(name))