From 2697093ac151f74eea3022951d128acfe04d1dcf Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Fri, 26 Mar 2021 14:45:18 +0000 Subject: [PATCH] fix: empty archive name on directory download --- http/raw.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/http/raw.go b/http/raw.go index 5c224caa..b9ac8159 100644 --- a/http/raw.go +++ b/http/raw.go @@ -181,14 +181,14 @@ 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 := filepath.Base(commonDir) + if name == "." || name == "" || name == string(filepath.Separator) { name = file.Name } - if name == "." || name == "" { - name = "archive" + // Prefix used to distinguish a filelist generated + // archive from the full directory archive + if len(filenames) > 1 { + name = "_" + name } name += extension w.Header().Set("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(name))