fix crash - segment fault when partialFile.Allocated() is invoked.

When openPartialFile is invoked, more errors than "existed error" are
returned. If only existing error is checked, the allocated field of
partialFile may be nil.

Signed-off-by: Star.LI <star@trapdoortech.com>
This commit is contained in:
Star.LI 2020-09-01 17:22:53 +08:00 committed by Star.LI
parent b8bbbf3ea3
commit 82f5984de1

View File

@ -371,7 +371,7 @@ func (sb *Sealer) ReadPiece(ctx context.Context, writer io.Writer, sector abi.Se
maxPieceSize := abi.PaddedPieceSize(sb.ssize)
pf, err := openPartialFile(maxPieceSize, path.Unsealed)
if xerrors.Is(err, os.ErrNotExist) {
if err != nil {
return false, xerrors.Errorf("opening partial file: %w", err)
}