Fix issue #112
This commit is contained in:
parent
011838998e
commit
4d10fd3496
10
misc.go
10
misc.go
|
@ -62,8 +62,14 @@ func validateInfo(info *metainfo.Info) error {
|
|||
if len(info.Pieces)%20 != 0 {
|
||||
return errors.New("pieces has invalid length")
|
||||
}
|
||||
if int((info.TotalLength()+info.PieceLength-1)/info.PieceLength) != info.NumPieces() {
|
||||
return errors.New("piece count and file lengths are at odds")
|
||||
if info.PieceLength == 0 {
|
||||
if info.TotalLength() != 0 {
|
||||
return errors.New("zero piece length")
|
||||
}
|
||||
} else {
|
||||
if int((info.TotalLength()+info.PieceLength-1)/info.PieceLength) != info.NumPieces() {
|
||||
return errors.New("piece count and file lengths are at odds")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue