Skip to content

Commit

Permalink
Refactor TorrentInfoEndpoint to fix JSON encoding issue
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
drew2a committed Jan 24, 2024
1 parent 7ca5ecc commit bec95d5
Showing 1 changed file with 0 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit bec95d5

Please sign in to comment.