Torrent.MetaInfo: don't crash if info isn't available yet
This commit is contained in:
parent
56a89905b6
commit
d8dc3ad239
12
torrent.go
12
torrent.go
|
@ -456,17 +456,17 @@ func (t *Torrent) announceList() (al [][]string) {
|
||||||
|
|
||||||
// Returns a run-time generated MetaInfo that includes the info bytes and
|
// Returns a run-time generated MetaInfo that includes the info bytes and
|
||||||
// announce-list as currently known to the client.
|
// announce-list as currently known to the client.
|
||||||
func (t *Torrent) newMetaInfo() *metainfo.MetaInfo {
|
func (t *Torrent) newMetaInfo() (mi *metainfo.MetaInfo) {
|
||||||
if t.metadataBytes == nil {
|
mi = &metainfo.MetaInfo{
|
||||||
panic("info bytes not set")
|
|
||||||
}
|
|
||||||
return &metainfo.MetaInfo{
|
|
||||||
Info: *t.info,
|
|
||||||
CreationDate: time.Now().Unix(),
|
CreationDate: time.Now().Unix(),
|
||||||
Comment: "dynamic metainfo from client",
|
Comment: "dynamic metainfo from client",
|
||||||
CreatedBy: "go.torrent",
|
CreatedBy: "go.torrent",
|
||||||
AnnounceList: t.announceList(),
|
AnnounceList: t.announceList(),
|
||||||
}
|
}
|
||||||
|
if t.info != nil {
|
||||||
|
mi.Info = *t.info
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Torrent) bytesLeft() (left int64) {
|
func (t *Torrent) bytesLeft() (left int64) {
|
||||||
|
|
Loading…
Reference in New Issue