fix: lookup directory name if blank when downloading shared directory

This commit is contained in:
Ryan authored and GitHub committed 2025-07-05 08:15:17 +02:00
1 parent 244fda2f2c
commit 046d6193c5
1 file changed
+12 -1
+12 -1
View File
@@ -177,7 +177,18 @@ func rawDirHandler(w http.ResponseWriter, r *http.Request, d *data, file *files.
name := filepath.Base(commonDir)
if name == "." || name == "" || name == string(filepath.Separator) {
name = file.Name
// Not sure when/if this will ever be true, though kept incase there is an edge-case where it is
if file.Name != "" {
name = file.Name
} else {
// This should indicate that the fs root is the directory being downloaded, lookup its name
actual, statErr := file.Fs.Stat(".")
if statErr != nil {
return http.StatusInternalServerError, statErr
}
name = actual.Name()
}
}
// Prefix used to distinguish a filelist generated
// archive from the full directory archive