sectorbuilder: open FD later in AddPiece

This commit is contained in:
Łukasz Magiera 2019-11-20 18:28:14 +01:00
parent 65c669b0f2
commit 7690c2f3b7

View File

@ -170,14 +170,14 @@ func (sb *SectorBuilder) AcquireSectorId() (uint64, error) {
}
func (sb *SectorBuilder) AddPiece(pieceSize uint64, sectorId uint64, file io.Reader, existingPieceSizes []uint64) (PublicPieceInfo, error) {
ret := sb.RateLimit()
defer ret()
f, werr, err := toReadableFile(file, int64(pieceSize))
if err != nil {
return PublicPieceInfo{}, err
}
ret := sb.RateLimit()
defer ret()
stagedFile, err := sb.stagedSectorFile(sectorId)
if err != nil {
return PublicPieceInfo{}, err