Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for adding FFA torrents with trackers #8327

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading