Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
bump go-unixfsnode and enable returning the sizes of items in HAMT di…
Browse files Browse the repository at this point in the history
…rectories for dir_index.html rendering
  • Loading branch information
aschmahmann committed Aug 10, 2023
1 parent 4958149 commit 688d15c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/ipfs/go-cid v0.4.1
github.com/ipfs/go-ipld-format v0.5.0
github.com/ipfs/go-log/v2 v2.5.1
github.com/ipfs/go-unixfsnode v1.7.3-0.20230718163022-62f4a1c8d46e
github.com/ipfs/go-unixfsnode v1.7.4
github.com/ipld/go-car v0.6.2
github.com/ipld/go-car/v2 v2.10.2-0.20230622090957-499d0c909d33
github.com/ipld/go-codec-dagpb v1.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fG
github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY=
github.com/ipfs/go-peertaskqueue v0.8.1 h1:YhxAs1+wxb5jk7RvS0LHdyiILpNmRIRnZVztekOF0pg=
github.com/ipfs/go-unixfs v0.4.5 h1:wj8JhxvV1G6CD7swACwSKYa+NgtdWC1RUit+gFnymDU=
github.com/ipfs/go-unixfsnode v1.7.3-0.20230718163022-62f4a1c8d46e h1:LZkN2wQ49qj4g47ET4OgsI7gZ/8mFMbdXNvAoESC54U=
github.com/ipfs/go-unixfsnode v1.7.3-0.20230718163022-62f4a1c8d46e/go.mod h1:PVfoyZkX1B34qzT3vJO4nsLUpRCyhnMuHBznRcXirlk=
github.com/ipfs/go-unixfsnode v1.7.4 h1:iLvKyAVKUYOIAW2t4kDYqsT7VLGj31eXJE2aeqGfbwA=
github.com/ipfs/go-unixfsnode v1.7.4/go.mod h1:PVfoyZkX1B34qzT3vJO4nsLUpRCyhnMuHBznRcXirlk=
github.com/ipfs/go-verifcid v0.0.2 h1:XPnUv0XmdH+ZIhLGKg6U2vaPaRDXb9urMyNVCE7uvTs=
github.com/ipfs/go-verifcid v0.0.2/go.mod h1:40cD9x1y4OWnFXbLNJYRe7MpNvWlMn3LZAG5Wb4xnPU=
github.com/ipld/go-car v0.6.2 h1:Hlnl3Awgnq8icK+ze3iRghk805lu8YNq3wlREDTF2qc=
Expand Down
17 changes: 15 additions & 2 deletions lib/graph_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"context"
"errors"
"fmt"
"github.com/ipfs/go-unixfsnode"
ufsiter "github.com/ipfs/go-unixfsnode/iter"
"io"
"net/http"
gopath "path"
Expand All @@ -27,7 +29,6 @@ import (
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
format "github.com/ipfs/go-ipld-format"
"github.com/ipfs/go-unixfsnode"
ufsData "github.com/ipfs/go-unixfsnode/data"
"github.com/ipfs/go-unixfsnode/hamt"
carv2 "github.com/ipld/go-car/v2"
Expand Down Expand Up @@ -694,6 +695,7 @@ func (it *backpressuredHAMTDirIterNoRecursion) Next() bool {
it.err = err
return false
}

var lnk ipld.Link
lnk, err = v.AsLink()
if err != nil {
Expand All @@ -709,10 +711,21 @@ func (it *backpressuredHAMTDirIterNoRecursion) Next() bool {

c := cl.Cid

pbLnk, ok := v.(*ufsiter.IterLink)
if !ok {
it.err = fmt.Errorf("HAMT value is not a dag-pb link")
return false
}

cumulativeDagSize := uint64(0)
if pbLnk.Substrate.Tsize.Exists() {
cumulativeDagSize = uint64(pbLnk.Substrate.Tsize.Must().Int())
}

it.curLnk = unixfs.LinkResult{
Link: &format.Link{
Name: name,
Size: 0,
Size: cumulativeDagSize,
Cid: c,
},
}
Expand Down

0 comments on commit 688d15c

Please sign in to comment.