fileserver: More filetypes for browse icons

This commit is contained in:
Matthew Holt
2023-05-19 09:59:40 -06:00
parent 2d236ead3e
commit bd34cb6b4e
3 changed files with 190 additions and 26 deletions

View File

@ -93,7 +93,7 @@ func (fsrv *FileServer) serveBrowse(root, dirPath string, w http.ResponseWriter,
return caddyhttp.Error(http.StatusInternalServerError, err)
}
fsrv.browseApplyQueryParams(w, r, &listing)
fsrv.browseApplyQueryParams(w, r, listing)
buf := bufPool.Get().(*bytes.Buffer)
buf.Reset()
@ -137,10 +137,10 @@ func (fsrv *FileServer) serveBrowse(root, dirPath string, w http.ResponseWriter,
return nil
}
func (fsrv *FileServer) loadDirectoryContents(ctx context.Context, dir fs.ReadDirFile, root, urlPath string, repl *caddy.Replacer) (browseTemplateContext, error) {
func (fsrv *FileServer) loadDirectoryContents(ctx context.Context, 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 && err != io.EOF {
return browseTemplateContext{}, err
return nil, err
}
// user can presumably browse "up" to parent folder if path is longer than "/"
@ -237,7 +237,7 @@ func isSymlink(f fs.FileInfo) bool {
// features.
type templateContext struct {
templates.TemplateContext
browseTemplateContext
*browseTemplateContext
}
// bufPool is used to increase the efficiency of file listings.