diff --git a/extern/sector-storage/ffiwrapper/sealer_cgo.go b/extern/sector-storage/ffiwrapper/sealer_cgo.go index 18a4e64cb..ea64fb36e 100644 --- a/extern/sector-storage/ffiwrapper/sealer_cgo.go +++ b/extern/sector-storage/ffiwrapper/sealer_cgo.go @@ -380,11 +380,11 @@ func (sb *Sealer) tryDecodeUpdatedReplica(ctx context.Context, sector storage.Se } defer done() - sealedPaths, releaseSectorKey, err := sb.AcquireSectorKeyOrRegenerate(ctx, sector, randomness) + sealedPaths, done2, err := sb.AcquireSectorKeyOrRegenerate(ctx, sector, randomness) if err != nil { return false, xerrors.Errorf("acquiring sealed sector: %w", err) } - defer releaseSectorKey() + defer done2() // Sector data stored in replica update updateProof, err := sector.ProofType.RegisteredUpdateProof() diff --git a/extern/sector-storage/manager.go b/extern/sector-storage/manager.go index 10869a65f..fcbe141b0 100644 --- a/extern/sector-storage/manager.go +++ b/extern/sector-storage/manager.go @@ -282,11 +282,15 @@ func (m *Manager) SectorsUnsealPiece(ctx context.Context, sector storage.SectorR sealFetch := func(ctx context.Context, worker Worker) error { log.Debugf("copy sealed/cache sector data for sector %d", sector.ID) _, err := m.waitSimpleCall(ctx)(worker.Fetch(ctx, sector, storiface.FTSealed|storiface.FTCache, storiface.PathSealing, storiface.AcquireCopy)) - if err != nil { - _, err2 := m.waitSimpleCall(ctx)(worker.Fetch(ctx, sector, storiface.FTUpdate|storiface.FTUpdateCache, storiface.PathSealing, storiface.AcquireCopy)) - if err2 != nil { - return xerrors.Errorf("copy sealed/cache sector data: %w %w", err, err2) - } + if err != nil && !xerrors.Is(err, storiface.ErrSectorNotFound) { + return err + } + _, err2 := m.waitSimpleCall(ctx)(worker.Fetch(ctx, sector, storiface.FTUpdate|storiface.FTUpdateCache, storiface.PathSealing, storiface.AcquireCopy)) + if err2 != nil && !xerrors.Is(err, storiface.ErrSectorNotFound) { + return err + } + if err != nil && err2 != nil { + return xerrors.Errorf("cannot unseal piece. No sealed or updated sector found") } return nil