ffiwrapper: Correctly create unsealed file when doesn't exist
This commit is contained in:
parent
e74eb6af09
commit
8ea44e82d1
@ -10,6 +10,7 @@ import (
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"math/bits"
|
||||
"os"
|
||||
@ -567,8 +568,15 @@ func (sb *Sealer) UnsealPiece(ctx context.Context, sector storiface.SectorRef, o
|
||||
|
||||
pf, err = partialfile.OpenPartialFile(maxPieceSize, unsealedPath.Unsealed)
|
||||
if err != nil {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
pf, err = partialfile.CreatePartialFile(maxPieceSize, unsealedPath.Unsealed)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("creating partial file: %w", err)
|
||||
}
|
||||
} else {
|
||||
return xerrors.Errorf("opening partial file: %w", err)
|
||||
}
|
||||
}
|
||||
defer pf.Close() // nolint
|
||||
|
||||
allocated, err := pf.Allocated()
|
||||
|
Loading…
Reference in New Issue
Block a user