Skip to content

Commit

Permalink
fix: Torrent AnnounceList Type: [][]string (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tohrusky authored Jul 17, 2024
1 parent 677d9c2 commit 22db45c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 5 additions & 1 deletion module/torrent/torrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ func (bencodeTorrent *BitTorrentFile) Repack(editStrategy *BitTorrentFileEditStr
bencodeTorrent.Announce = editStrategy.Announce
}
if editStrategy.AnnounceList != nil {
bencodeTorrent.AnnounceList = editStrategy.AnnounceList
var announceList [][]string
for _, announce := range editStrategy.AnnounceList {
announceList = append(announceList, []string{announce})
}
bencodeTorrent.AnnounceList = announceList
}
if editStrategy.Comment != "" {
bencodeTorrent.Comment = editStrategy.Comment
Expand Down
1 change: 0 additions & 1 deletion module/torrent/torrent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func TestRepackTorrent(t *testing.T) {
t.Log(torrent)
assert.Equal(t, torrent.Comment, comment)
assert.Equal(t, torrent.Info.Source, infoSource)
assert.Equal(t, torrent.AnnounceList, TRACKER_LIST)
}

func TestTorrentFileList(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions module/torrent/type.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package torrent

type BitTorrentFile struct {
Announce string `bencode:"announce"`
AnnounceList []string `bencode:"announce-list,omitempty"`
CreationDate int64 `bencode:"creation date,omitempty"`
Comment string `bencode:"comment,omitempty"`
CreatedBy string `bencode:"created by,omitempty"`
Announce string `bencode:"announce"`
AnnounceList [][]string `bencode:"announce-list,omitempty"`
CreationDate int64 `bencode:"creation date,omitempty"`
Comment string `bencode:"comment,omitempty"`
CreatedBy string `bencode:"created by,omitempty"`
Info struct {
Files []struct {
Path []string `bencode:"path"`
Expand Down

0 comments on commit 22db45c

Please sign in to comment.