sectorstorage: Fix potential panic in FinalizeSector

This commit is contained in:
Łukasz Magiera 2020-09-29 15:22:46 +02:00
parent 867ca2f25d
commit baef3c8dd2

View File

@ -546,10 +546,7 @@ func (sb *Sealer) FinalizeSector(ctx context.Context, sector abi.SectorID, keepU
defer done()
pf, err := openPartialFile(maxPieceSize, paths.Unsealed)
if xerrors.Is(err, os.ErrNotExist) {
return xerrors.Errorf("opening partial file: %w", err)
}
if err == nil {
var at uint64
for sr.HasNext() {
r, err := sr.NextRun()
@ -574,6 +571,12 @@ func (sb *Sealer) FinalizeSector(ctx context.Context, sector abi.SectorID, keepU
if err := pf.Close(); err != nil {
return err
}
} else {
if !xerrors.Is(err, os.ErrNotExist) {
return xerrors.Errorf("opening partial file: %w", err)
}
}
}
paths, done, err := sb.sectors.AcquireSector(ctx, sector, stores.FTCache, 0, stores.PathStorage)