fileserver: Ignore EOF when browsing empty dir

Thanks to @WeidiDeng for reporting this
This commit is contained in:
Matthew Holt 2022-09-07 21:14:11 -06:00
parent dd9813c65b
commit c19f207237
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5

View File

@ -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
}