Don't error on setting info when we already have it
This commit is contained in:
parent
91afef8733
commit
e33d773391
10
torrent.go
10
torrent.go
|
@ -377,9 +377,6 @@ func (t *Torrent) cacheLength() {
|
|||
}
|
||||
|
||||
func (t *Torrent) setInfo(info *metainfo.Info) error {
|
||||
if t.info != nil {
|
||||
return errors.New("info already set")
|
||||
}
|
||||
if err := validateInfo(info); err != nil {
|
||||
return fmt.Errorf("bad info: %s", err)
|
||||
}
|
||||
|
@ -431,11 +428,14 @@ func (t *Torrent) setInfoBytes(b []byte) error {
|
|||
if err := bencode.Unmarshal(b, &info); err != nil {
|
||||
return fmt.Errorf("error unmarshalling info bytes: %s", err)
|
||||
}
|
||||
t.metadataBytes = b
|
||||
t.metadataCompletedChunks = nil
|
||||
if t.info != nil {
|
||||
return nil
|
||||
}
|
||||
if err := t.setInfo(&info); err != nil {
|
||||
return err
|
||||
}
|
||||
t.metadataBytes = b
|
||||
t.metadataCompletedChunks = nil
|
||||
t.onSetInfo()
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue