Don't error on setting info when we already have it

This commit is contained in:
Matt Joiner 2020-05-19 15:22:58 +10:00
parent 91afef8733
commit e33d773391
1 changed files with 5 additions and 5 deletions

View File

@ -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
}