From c19f2072379e18fbf3b2409ecd49ca023d62b882 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Wed, 7 Sep 2022 21:14:11 -0600 Subject: [PATCH] fileserver: Ignore EOF when browsing empty dir Thanks to @WeidiDeng for reporting this --- modules/caddyhttp/fileserver/browse.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/caddyhttp/fileserver/browse.go b/modules/caddyhttp/fileserver/browse.go index 7804d19b7..6a72e155a 100644 --- a/modules/caddyhttp/fileserver/browse.go +++ b/modules/caddyhttp/fileserver/browse.go @@ -19,6 +19,7 @@ import ( _ "embed" "encoding/json" "fmt" + "io" "io/fs" "net/http" "os" @@ -137,7 +138,7 @@ func (fsrv *FileServer) serveBrowse(root, dirPath string, w http.ResponseWriter, func (fsrv *FileServer) loadDirectoryContents(dir fs.ReadDirFile, root, urlPath string, repl *caddy.Replacer) (browseTemplateContext, error) { files, err := dir.ReadDir(10000) // TODO: this limit should probably be configurable - if err != nil { + if err != nil && err != io.EOF { return browseTemplateContext{}, err }