diff options
Diffstat (limited to 'object/fetch/treefs.go')
| -rw-r--r-- | object/fetch/treefs.go | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/object/fetch/treefs.go b/object/fetch/treefs.go index da92af51..d12e3dd6 100644 --- a/object/fetch/treefs.go +++ b/object/fetch/treefs.go @@ -1,17 +1,16 @@ package fetch import ( + "bytes" "errors" "fmt" "io" "io/fs" - "strings" "time" oid "lindenii.org/go/furgit/object/id" "lindenii.org/go/furgit/object/tree" "lindenii.org/go/furgit/object/tree/mode" - "lindenii.org/go/lgo/intconv" ) // TreeFS exposes one Git tree as an fs.FS view backed by a Fetcher. @@ -49,12 +48,12 @@ var ErrGitlinkNotFile = fmt.Errorf("%w: object/fetch: gitlink entries are not re // generic fs consumers classify it correctly. var ErrIsDirectory = fmt.Errorf("%w: object/fetch: is a directory", fs.ErrInvalid) -func splitPath(path string) []string { +func splitPath(path string) [][]byte { if len(path) == 0 { return nil } - return strings.Split(path, "/") + return bytes.Split([]byte(path), []byte("/")) } type treeEntryValue struct { @@ -69,7 +68,7 @@ func (entry treeEntryValue) isDir() bool { return entry.mode == mode.Directory } -func (entry treeEntryValue) blobSize(fetcher *Fetcher) (uint64, error) { +func (entry treeEntryValue) blobSize(fetcher *Fetcher) (int, error) { return fetcher.Size(entry.objectID) } @@ -198,7 +197,7 @@ func (treeFS *TreeFS) Open(name string) (fs.File, error) { entries := make([]fs.DirEntry, 0, len(tree.Object().Entries())) for _, child := range tree.Object().Entries() { childEntry := treeEntryValue{ - name: child.Name, + name: string(child.Name), mode: child.Mode, objectID: child.ID, treeEntry: &child, @@ -402,7 +401,7 @@ func (treeFS *TreeFS) resolvePath(op treeFSOp, name string) (treeEntryValue, err } return treeEntryValue{ - name: entry.Name, + name: string(entry.Name), mode: entry.Mode, objectID: entry.ID, treeEntry: &entry, @@ -434,10 +433,7 @@ func (treeFS *TreeFS) statEntry(entry treeEntryValue) (*treeFSInfo, error) { return nil, err } - size, err = intconv.Uint64ToInt64(sz) - if err != nil { - return nil, fmt.Errorf("object/fetch: blob size overflows int64: %w", err) - } + size = int64(sz) } var sys any |
