Skip to content

Commit

Permalink
show number of pieces in error message when there are too many (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabeguz authored Jan 24, 2024
1 parent 02ecc5a commit 2fc8913
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion torrent/session_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (s *Session) parseMetaInfo(r io.Reader) (*metainfo.MetaInfo, error) {
return nil, err
}
if mi.Info.NumPieces > s.config.MaxPieces {
return nil, errTooManyPieces
return nil, fmt.Errorf("too many pieces: %d", mi.Info.NumPieces)
}
return mi, nil
}
Expand Down
5 changes: 1 addition & 4 deletions torrent/session_load.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package torrent

import (
"errors"
"fmt"

"github.com/cenkalti/rain/internal/bitfield"
Expand All @@ -13,8 +12,6 @@ import (
"go.etcd.io/bbolt"
)

var errTooManyPieces = errors.New("too many pieces")

func (s *Session) loadExistingTorrents(ids []string) {
var loaded int
var started []*Torrent
Expand Down Expand Up @@ -57,7 +54,7 @@ func (s *Session) parseInfo(b []byte, version int) (*metainfo.Info, error) {
return nil, err
}
if i.NumPieces > s.config.MaxPieces {
return nil, errTooManyPieces
return nil, fmt.Errorf("too many pieces: %d", i.NumPieces)
}
return i, nil
}
Expand Down

0 comments on commit 2fc8913

Please sign in to comment.