From bec95d5acd53031fed435e49fe65e97005e1b0ea Mon Sep 17 00:00:00 2001 From: drew2a Date: Mon, 22 Jan 2024 23:04:13 +0700 Subject: [PATCH] Refactor TorrentInfoEndpoint to fix JSON encoding issue The code changes in this commit refactor the TorrentInfoEndpoint class in order to fix a JSON encoding issue. The previous implementation used json.dumps, which garbled binary data in the 'pieces' field. This commit removes that line of code and ensures that the GUI does not rely on this field. --- .../core/components/libtorrent/restapi/torrentinfo_endpoint.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/tribler/core/components/libtorrent/restapi/torrentinfo_endpoint.py b/src/tribler/core/components/libtorrent/restapi/torrentinfo_endpoint.py index 3f2cf06d1ef..f9cf04e435e 100644 --- a/src/tribler/core/components/libtorrent/restapi/torrentinfo_endpoint.py +++ b/src/tribler/core/components/libtorrent/restapi/torrentinfo_endpoint.py @@ -154,9 +154,6 @@ async def get_torrent_info(self, request): # Check if the torrent is already in the downloads encoded_metainfo = deepcopy(metainfo) - # FIXME: json.dumps garbles binary data that is used by the 'pieces' field - # However, this is fine as long as the GUI does not use this field. - encoded_metainfo[b'info'][b'pieces'] = hexlify(encoded_metainfo[b'info'][b'pieces']).encode('utf-8') encoded_metainfo = hexlify(json.dumps(recursive_unicode( encoded_metainfo, ignore_errors=True), ensure_ascii=False).encode('utf-8')) return RESTResponse({"metainfo": encoded_metainfo,