Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Commit

Permalink
fix: type of contents in serialfile
Browse files Browse the repository at this point in the history
  • Loading branch information
galargh committed Sep 1, 2022
1 parent 84dc4b8 commit 263276c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion serialfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package files
import (
"errors"
"fmt"
"io/fs"
"os"
"path/filepath"
)
Expand Down Expand Up @@ -51,10 +52,18 @@ func NewSerialFileWithFilter(path string, filter *Filter, stat os.FileInfo) (Nod
case mode.IsDir():
// for directories, stat all of the contents first, so we know what files to
// open when Entries() is called
contents, err := os.ReadDir(path)
entries, err := os.ReadDir(path)
if err != nil {
return nil, err
}
contents := make([]fs.FileInfo, 0, len(entries))
for _, entry := range entries {
content, err := entry.Info()
if err != nil {
return nil, err
}
contents = append(contents, content)
}
return &serialFile{path, contents, stat, filter}, nil
case mode&os.ModeSymlink != 0:
target, err := os.Readlink(path)
Expand Down

0 comments on commit 263276c

Please sign in to comment.