diff --git a/extern/filecoin-ffi b/extern/filecoin-ffi index 951d66ae9..b6e0b35fb 160000 --- a/extern/filecoin-ffi +++ b/extern/filecoin-ffi @@ -1 +1 @@ -Subproject commit 951d66ae93f6f4d3e26fee8c9320333c410f8bd1 +Subproject commit b6e0b35fb49ed0fedb6a6a473b222e3b8a7d7f17 diff --git a/go.mod b/go.mod index df0a11740..d8efe4a3d 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,7 @@ require ( github.com/filecoin-project/go-data-transfer v1.2.7 github.com/filecoin-project/go-fil-commcid v0.0.0-20201016201715-d41df56b4f6a github.com/filecoin-project/go-fil-markets v1.1.7 - github.com/filecoin-project/go-jsonrpc v0.1.2 + github.com/filecoin-project/go-jsonrpc v0.1.3 github.com/filecoin-project/go-multistore v0.0.3 github.com/filecoin-project/go-padreader v0.0.0-20200903213702-ed5fae088b20 github.com/filecoin-project/go-paramfetch v0.0.2-0.20200701152213-3e0f0afdc261 diff --git a/go.sum b/go.sum index a5c9828cc..70e789928 100644 --- a/go.sum +++ b/go.sum @@ -279,8 +279,8 @@ github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 h1:b3UDemBYN2HNfk3KOXNuxgTTxl github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0/go.mod h1:7aWZdaQ1b16BVoQUYR+eEvrDCGJoPLxFpDynFjYfBjI= github.com/filecoin-project/go-hamt-ipld/v3 v3.0.1 h1:zbzs46G7bOctkZ+JUX3xirrj0RaEsi+27dtlsgrTNBg= github.com/filecoin-project/go-hamt-ipld/v3 v3.0.1/go.mod h1:gXpNmr3oQx8l3o7qkGyDjJjYSRX7hp/FGOStdqrWyDI= -github.com/filecoin-project/go-jsonrpc v0.1.2 h1:MTebUawBHLxxY9gDi1WXuGc89TWIDmsgoDqeZSk9KRw= -github.com/filecoin-project/go-jsonrpc v0.1.2/go.mod h1:XBBpuKIMaXIIzeqzO1iucq4GvbF8CxmXRFoezRh+Cx4= +github.com/filecoin-project/go-jsonrpc v0.1.3 h1:Ep2PQzO1t3nUlUFXWuT12h7AfC4bZM3BjwfSDlpNzaQ= +github.com/filecoin-project/go-jsonrpc v0.1.3/go.mod h1:XBBpuKIMaXIIzeqzO1iucq4GvbF8CxmXRFoezRh+Cx4= github.com/filecoin-project/go-multistore v0.0.3 h1:vaRBY4YiA2UZFPK57RNuewypB8u0DzzQwqsL0XarpnI= github.com/filecoin-project/go-multistore v0.0.3/go.mod h1:kaNqCC4IhU4B1uyr7YWFHd23TL4KM32aChS0jNkyUvQ= github.com/filecoin-project/go-padreader v0.0.0-20200903213702-ed5fae088b20 h1:+/4aUeUoKr6AKfPE3mBhXA5spIV6UcKdTYDPNU2Tdmg= diff --git a/node/impl/client/client.go b/node/impl/client/client.go index 00c840b63..ac526ac60 100644 --- a/node/impl/client/client.go +++ b/node/impl/client/client.go @@ -711,6 +711,16 @@ func (a *API) ClientCalcCommP(ctx context.Context, inpath string) (*api.CommPRet return nil, err } + // check that the data is a car file; if it's not, retrieval won't work + _, _, err = car.ReadHeader(bufio.NewReader(rdr)) + if err != nil { + return nil, xerrors.Errorf("not a car file: %w", err) + } + + if _, err := rdr.Seek(0, io.SeekStart); err != nil { + return nil, xerrors.Errorf("seek to start: %w", err) + } + pieceReader, pieceSize := padreader.New(rdr, uint64(stat.Size())) commP, err := ffiwrapper.GeneratePieceCIDFromFile(arbitraryProofType, pieceReader, pieceSize)