Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't resolve children unnecessarily when listing a sharded directory #4884

Merged
merged 2 commits into from
Mar 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions test/sharness/t0260-sharding.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ test_expect_success "ipfs cat error output the same" '
test_cmp sharded_err unsharded_err
'

test_expect_success "'ipfs ls --resolve-type=false' admits missing block" '
ipfs ls "$SHARDED" | head -1 > first_file &&
read -r HASH _ NAME <first_file &&
ipfs pin rm "$SHARDED" "$UNSHARDED" && # To allow us to remove the block
ipfs block rm "$HASH" &&
test_expect_code 1 ipfs cat "$SHARDED/$NAME" &&
test_expect_code 1 ipfs ls "$SHARDED" &&
ipfs ls --resolve-type=false "$SHARDED" | sort > missing_out &&
test_cmp sharded_out missing_out
'


test_add_large_dir_v1() {
exphash="$1"
test_expect_success "ipfs add (CIDv1) on very large directory succeeds" '
Expand Down
10 changes: 5 additions & 5 deletions unixfs/hamt/hamt.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,13 @@ func (ds *Shard) loadChild(ctx context.Context, i int) (child, error) {
return nil, fmt.Errorf("invalid link name '%s'", lnk.Name)
}

nd, err := lnk.GetNode(ctx, ds.dserv)
if err != nil {
return nil, err
}

var c child
if len(lnk.Name) == ds.maxpadlen {
nd, err := lnk.GetNode(ctx, ds.dserv)
if err != nil {
return nil, err
}

pbnd, ok := nd.(*dag.ProtoNode)
if !ok {
return nil, dag.ErrNotProtobuf
Expand Down