From 47c59afea01f03dc3e34ac95b99e7f611cc1892a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 7 Sep 2020 20:12:29 +0200 Subject: [PATCH] Revert "storage manager: bail out with an error if unsealed cid is undefined" --- extern/sector-storage/manager.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/extern/sector-storage/manager.go b/extern/sector-storage/manager.go index 7513b2dbf..300958e39 100644 --- a/extern/sector-storage/manager.go +++ b/extern/sector-storage/manager.go @@ -217,11 +217,16 @@ func (m *Manager) ReadPiece(ctx context.Context, sink io.Writer, sector abi.Sect return xerrors.Errorf("read piece: checking for already existing unsealed sector: %w", err) } - var readOk bool var selector WorkerSelector if len(best) == 0 { // new selector = newAllocSelector(m.index, stores.FTUnsealed, stores.PathSealing) } else { // append to existing + selector = newExistingSelector(m.index, sector, stores.FTUnsealed, false) + } + + var readOk bool + + if len(best) > 0 { // There is unsealed sector, see if we can read from it selector = newExistingSelector(m.index, sector, stores.FTUnsealed, false) @@ -252,10 +257,6 @@ func (m *Manager) ReadPiece(ctx context.Context, sink io.Writer, sector abi.Sect return nil } - if unsealed == cid.Undef { - return xerrors.Errorf("cannot unseal piece (sector: %d, offset: %d size: %d) - unsealed cid is undefined", sector, offset, size) - } - err = m.sched.Schedule(ctx, sector, sealtasks.TTUnseal, selector, unsealFetch, func(ctx context.Context, w Worker) error { return w.UnsealPiece(ctx, sector, offset, size, ticket, unsealed) }) @@ -273,7 +274,7 @@ func (m *Manager) ReadPiece(ctx context.Context, sink io.Writer, sector abi.Sect return xerrors.Errorf("reading piece from sealed sector: %w", err) } - if !readOk { + if readOk { return xerrors.Errorf("failed to read unsealed piece") }