fix: lookup directory name if blank when downloading shared directory

This commit is contained in:
Ryan 2025-07-05 02:15:17 -04:00 committed by GitHub
parent 244fda2f2c
commit 046d6193c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -177,7 +177,18 @@ func rawDirHandler(w http.ResponseWriter, r *http.Request, d *data, file *files.
name := filepath.Base(commonDir) name := filepath.Base(commonDir)
if name == "." || name == "" || name == string(filepath.Separator) { 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 // Prefix used to distinguish a filelist generated
// archive from the full directory archive // archive from the full directory archive