fix: storage manager - bail out with an error if unsealed cid is undefined
This commit is contained in:
parent
0ad0d4ea11
commit
07a4553e6e
11
extern/sector-storage/manager.go
vendored
11
extern/sector-storage/manager.go
vendored
@ -217,16 +217,11 @@ 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)
|
return xerrors.Errorf("read piece: checking for already existing unsealed sector: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var readOk bool
|
||||||
var selector WorkerSelector
|
var selector WorkerSelector
|
||||||
if len(best) == 0 { // new
|
if len(best) == 0 { // new
|
||||||
selector = newAllocSelector(m.index, stores.FTUnsealed, stores.PathSealing)
|
selector = newAllocSelector(m.index, stores.FTUnsealed, stores.PathSealing)
|
||||||
} else { // append to existing
|
} 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
|
// There is unsealed sector, see if we can read from it
|
||||||
|
|
||||||
selector = newExistingSelector(m.index, sector, stores.FTUnsealed, false)
|
selector = newExistingSelector(m.index, sector, stores.FTUnsealed, false)
|
||||||
@ -257,6 +252,10 @@ func (m *Manager) ReadPiece(ctx context.Context, sink io.Writer, sector abi.Sect
|
|||||||
return nil
|
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 {
|
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)
|
return w.UnsealPiece(ctx, sector, offset, size, ticket, unsealed)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user