diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 4140a845ba..84a45b9ebc 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -27,6 +27,9 @@ jobs: - name: Build run: go build -v ./... + - name: Build Docs (to verify it works on PRs) + run: core build web -dir docs -o static + # we can't test gpu, xyz, and system on the CI since there is no Vulkan support - name: Test run: go test -v $(go list ./... | grep -v gpu | grep -v xyz | grep -v system) -coverprofile cover.out -timeout 30s diff --git a/base/fileinfo/fileinfo.go b/base/fileinfo/fileinfo.go index 0ef6bf11f4..2e4aa02d96 100644 --- a/base/fileinfo/fileinfo.go +++ b/base/fileinfo/fileinfo.go @@ -103,6 +103,10 @@ func NewFileInfoType(ftyp Known) *FileInfo { // but file info will be updated based on the filename even if // the file does not exist. func (fi *FileInfo) InitFile(fname string) error { + fi.Cat = UnknownCategory + fi.Known = Unknown + fi.Generated = false + fi.Kind = "" var errs []error path, err := filepath.Abs(fname) if err == nil { @@ -111,7 +115,6 @@ func (fi *FileInfo) InitFile(fname string) error { fi.Path = fname } _, fi.Name = filepath.Split(path) - fi.SetMimeInfo() info, err := os.Stat(fi.Path) if err != nil { errs = append(errs, err) @@ -126,10 +129,13 @@ func (fi *FileInfo) InitFile(fname string) error { // but file info will be updated based on the filename even if // the file does not exist. func (fi *FileInfo) InitFileFS(fsys fs.FS, fname string) error { + fi.Cat = UnknownCategory + fi.Known = Unknown + fi.Generated = false + fi.Kind = "" var errs []error fi.Path = fname _, fi.Name = path.Split(fname) - fi.SetMimeInfo() info, err := fs.Stat(fsys, fi.Path) if err != nil { errs = append(errs, err) @@ -145,10 +151,7 @@ func (fi *FileInfo) SetMimeInfo() error { if fi.Path == "" || fi.Path == "." || fi.IsDir() { return nil } - fi.Cat = UnknownCategory - fi.Known = Unknown fi.Generated = IsGeneratedFile(fi.Path) - fi.Kind = "" mtyp, _, err := MimeFromFile(fi.Path) if err != nil { return err @@ -177,6 +180,9 @@ func (fi *FileInfo) SetFileInfo(info fs.FileInfo) { fi.Cat = Folder fi.Known = AnyFolder } else { + if fi.Mode.IsRegular() { + fi.SetMimeInfo() + } if fi.Cat == UnknownCategory { if fi.IsExec() { fi.Cat = Exe