From 2134f165c0090e01b3f29404a8e094ccc7e8cabc Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Fri, 22 Apr 2022 14:29:35 +0200 Subject: [PATCH] Review fixes --- extern/sector-storage/ffiwrapper/sealer_cgo.go | 4 ++-- extern/sector-storage/manager.go | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/extern/sector-storage/ffiwrapper/sealer_cgo.go b/extern/sector-storage/ffiwrapper/sealer_cgo.go index 18a4e64cb2e..ea64fb36e62 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 10869a65f4d..fcbe141b068 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