1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

chore: minor performance improvements

This commit is contained in:
Ferdinand Mütsch
2021-12-20 16:41:50 +01:00
parent 80252ff701
commit e14f8c1463
3 changed files with 42 additions and 20 deletions

View File

@ -8,11 +8,11 @@ import (
// https://www.alexedwards.net/blog/disable-http-fileserver-directory-listings
type NeuteredFileSystem struct {
Fs fs.FS
fs.FS
}
func (nfs NeuteredFileSystem) Open(path string) (fs.File, error) {
f, err := nfs.Fs.Open(path)
f, err := nfs.FS.Open(path)
if err != nil {
return nil, err
}
@ -20,7 +20,7 @@ func (nfs NeuteredFileSystem) Open(path string) (fs.File, error) {
s, err := f.Stat()
if s.IsDir() {
index := filepath.Join(path, "index.html")
if _, err := nfs.Fs.Open(index); err != nil {
if _, err := nfs.FS.Open(index); err != nil {
closeErr := f.Close()
if closeErr != nil {
return nil, closeErr