Skip to content

Commit

Permalink
Fix for adding FFA torrents with trackers
Browse files Browse the repository at this point in the history
  • Loading branch information
egbertbouman committed Dec 10, 2024
1 parent 0a2742c commit fd3cb71
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/tribler/core/database/orm_bindings/torrent_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ def add_ffa_from_dict(cls: type[Self], metadata: dict) -> Self | None:
pk_blob = b""
if cls.exists(lambda g: (g.infohash == ih_blob) or (g.id_ == id_ and g.public_key == pk_blob)):
return None
if isinstance(metadata.get("tracker_info", ""), bytes):
metadata["tracker_info"] = metadata["tracker_info"].decode()
# Add the torrent as a free-for-all entry if it is unknown to GigaChannel
return cls.from_dict(dict(metadata, public_key=b'', status=COMMITTED, id_=id_))

Expand Down
9 changes: 9 additions & 0 deletions src/tribler/test_unit/core/database/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ def test_process_payload_ffa(self) -> None:
self.assertIsNotNone(self.metadata_store.TorrentMetadata.get(title=ffa_title))
self.assertEqual([], self.metadata_store.process_payload(ffa_payload))

@db_session
def test_ffa_with_tracker_info(self) -> None:
"""
Test if FFA entries are correctly added when they have tracker_info.
"""
self.metadata_store.TorrentMetadata.add_ffa_from_dict({"infohash": b"1" * 20,
"title": "abcabc",
"tracker_info": b"http://tracker/announce"})

@db_session
def test_get_entries_query_sort_by_size(self) -> None:
"""
Expand Down

0 comments on commit fd3cb71

Please sign in to comment.