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

fix: remove on-the-fly indexing #1875

Merged
merged 2 commits into from
Jan 24, 2024
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
15 changes: 1 addition & 14 deletions piecedirectory/piecedirectory.go
Original file line number Diff line number Diff line change
Expand Up @@ -885,21 +885,8 @@ func (ps *PieceDirectory) BlockstoreGetSize(ctx context.Context, c cid.Cid) (int
return int(offsetSize.Size), nil
}

// The index is incomplete, so re-build the index on the fly
err = ps.BuildIndexForPiece(ctx, p)
if err != nil {
merr = multierror.Append(merr, fmt.Errorf("re-building index for piece %s: %w", p, err))
continue
}

// Now get the size again
offsetSize, err = ps.GetOffsetSize(ctx, p, c.Hash())
if err != nil {
merr = multierror.Append(merr, fmt.Errorf("getting size of cid %s in piece %s: %w", c, p, err))
continue
}
merr = multierror.Append(merr, fmt.Errorf("piece %s is not indexed correctly", p))

return int(offsetSize.Size), nil
}

return 0, merr
Expand Down
2 changes: 2 additions & 0 deletions piecedirectory/piecedirectory_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ func testImportedIndex(ctx context.Context, t *testing.T, cl *client.Store) {
// directory should re-build the index and then return the size.
pm := NewPieceDirectory(cl, pr, 1)
pm.Start(ctx)
err = pm.BuildIndexForPiece(ctx, pieceCid)
require.NoError(t, err)
sz, err := pm.BlockstoreGetSize(ctx, rec.Cid)
require.NoError(t, err)
require.Equal(t, len(blk.RawData()), sz)
Expand Down