You've already forked torrent-client
mirror of
https://github.com/veggiedefender/torrent-client.git
synced 2025-11-06 09:29:16 +02:00
Return plain struct from toTorrentFile
This commit is contained in:
@@ -65,11 +65,11 @@ func (t *TorrentFile) Download() ([]byte, error) {
|
||||
}
|
||||
|
||||
// Open parses a torrent file
|
||||
func Open(r io.Reader) (*TorrentFile, error) {
|
||||
func Open(r io.Reader) (TorrentFile, error) {
|
||||
bto := bencodeTorrent{}
|
||||
err := bencode.Unmarshal(r, &bto)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return TorrentFile{}, err
|
||||
}
|
||||
return bto.toTorrentFile()
|
||||
}
|
||||
@@ -100,14 +100,14 @@ func (i *bencodeInfo) splitPieceHashes() ([][20]byte, error) {
|
||||
return hashes, nil
|
||||
}
|
||||
|
||||
func (bto *bencodeTorrent) toTorrentFile() (*TorrentFile, error) {
|
||||
func (bto *bencodeTorrent) toTorrentFile() (TorrentFile, error) {
|
||||
infoHash, err := bto.Info.hash()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return TorrentFile{}, err
|
||||
}
|
||||
pieceHashes, err := bto.Info.splitPieceHashes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return TorrentFile{}, err
|
||||
}
|
||||
t := TorrentFile{
|
||||
Announce: bto.Announce,
|
||||
@@ -117,5 +117,5 @@ func (bto *bencodeTorrent) toTorrentFile() (*TorrentFile, error) {
|
||||
Length: bto.Info.Length,
|
||||
Name: bto.Info.Name,
|
||||
}
|
||||
return &t, nil
|
||||
return t, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user