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"
|
"crypto/rand"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"math/bits"
|
"math/bits"
|
||||||
"os"
|
"os"
|
||||||
@ -567,7 +568,14 @@ func (sb *Sealer) UnsealPiece(ctx context.Context, sector storiface.SectorRef, o
|
|||||||
|
|
||||||
pf, err = partialfile.OpenPartialFile(maxPieceSize, unsealedPath.Unsealed)
|
pf, err = partialfile.OpenPartialFile(maxPieceSize, unsealedPath.Unsealed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("opening partial file: %w", err)
|
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
|
defer pf.Close() // nolint
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user