fix: add special case to check for an index.html, and pass root and root type

This commit is contained in:
Derrick Hammer 2024-03-03 08:29:07 -05:00
parent bd5544198e
commit 080fcbd559
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 14 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package s5
import ( import (
"errors" "errors"
"io/fs" "io/fs"
"path"
"git.lumeweb.com/LumeWeb/libs5-go/encoding" "git.lumeweb.com/LumeWeb/libs5-go/encoding"
"git.lumeweb.com/LumeWeb/libs5-go/metadata" "git.lumeweb.com/LumeWeb/libs5-go/metadata"
@ -43,7 +44,19 @@ func (w webAppFs) Open(name string) (fs.File, error) {
item, ok := webApp.Paths.Get(name) item, ok := webApp.Paths.Get(name)
if !ok { if !ok {
return nil, fs.ErrNotExist name = path.Join(name, "index.html")
item, ok = webApp.Paths.Get(name)
if !ok {
return nil, fs.ErrNotExist
}
return w.s5.newFile(FileParams{
Hash: item.Cid.Hash.HashBytes(),
Type: item.Cid.Type,
Name: name,
Root: w.root.Hash.HashBytes(),
RootType: w.root.Type,
}), nil
} }
return w.s5.newFile(FileParams{ return w.s5.newFile(FileParams{
Hash: item.Cid.Hash.HashBytes(), Hash: item.Cid.Hash.HashBytes(),