changes as per review

This commit is contained in:
aarshkshah1992 2021-06-04 10:27:43 +05:30
parent 43453bb633
commit 05ba3de5cc

View File

@ -53,14 +53,14 @@ func (p *pieceProvider) IsUnsealed(ctx context.Context, sector storage.SectorRef
return false, xerrors.Errorf("size is not a valid piece size: %w", err) return false, xerrors.Errorf("size is not a valid piece size: %w", err)
} }
ctx, cancel := context.WithCancel(ctx) ctxLock, cancel := context.WithCancel(ctx)
if err := p.index.StorageLock(ctx, sector.ID, storiface.FTUnsealed, storiface.FTNone); err != nil {
cancel()
return false, xerrors.Errorf("acquiring read sector lock: %w", err)
}
defer cancel() defer cancel()
return p.storage.CheckIsUnsealed(ctx, sector, abi.PaddedPieceSize(offset.Padded()), size.Padded()) if err := p.index.StorageLock(ctxLock, sector.ID, storiface.FTUnsealed, storiface.FTNone); err != nil {
return false, xerrors.Errorf("acquiring read sector lock: %w", err)
}
return p.storage.CheckIsUnsealed(ctxLock, sector, abi.PaddedPieceSize(offset.Padded()), size.Padded())
} }
// tryReadUnsealedPiece will try to read the unsealed piece from an existing unsealed sector file for the given sector from any worker that has it. // tryReadUnsealedPiece will try to read the unsealed piece from an existing unsealed sector file for the given sector from any worker that has it.