If you upload a torrent file, it calculates the right info-hash, but when you download the torrent file, the torrent has a different info-hash.
You can try with this torrent:
torrent-without-private-field.txt.zip
{
"created by": "imdl/0.1.13",
"creation date": 1694545594,
"encoding": "UTF-8",
"info": {
"length": 30,
"name": "torrent-without-private-field.txt",
"piece length": 16384,
"pieces": "<hex>87 F9 9A 42 68 8D AE 18 E5 72 1D 7C 37 7B 88 91 E0 2D 08 9E</hex>"
}
}
$ imdl torrent show torrent-without-private-field.txt.torrent
Name torrent-without-private-field.txt
Creation Date 2023-09-12 19:06:34 UTC
Created By imdl/0.1.13
Info Hash a65c2b8d13e9ea21936e40a5810f3ea7e6a3f26e
Torrent Size 189 bytes
Content Size 30 bytes
Private no
Piece Size 16 KiB
Piece Count 1
File Count 1
Files torrent-without-private-field.txt
The downloaded version is:
downloaded-torrent-without-private-field.txt.zip
{
"announce": "udp://localhost:6969",
"announce-list": [
[
"udp://localhost:6969"
]
],
"info": {
"length": 30,
"name": "torrent-without-private-field.txt",
"piece length": 16384,
"pieces": "<hex>87 F9 9A 42 68 8D AE 18 E5 72 1D 7C 37 7B 88 91 E0 2D 08 9E</hex>",
"private": 0
}
}
$ imdl torrent show downloaded-torrent-without-private-field.txt.torrent
Name torrent-without-private-field.txt
Info Hash 410511dffe82a1b3136559aaf38a43d3b0ecbba4
Torrent Size 205 bytes
Content Size 30 bytes
Private no
Tracker udp://localhost:6969
Announce List Tier 1: udp://localhost:6969
Piece Size 16 KiB
Piece Count 1
File Count 1
Files torrent-without-private-field.txt
I think the problem is we always include the private field in the info dictionary even if the field was not present in the original torrent.
I think we have to set the field torrust_torrents::private column in the database to NULL when the original torrent does not include that field instead of setting the value to false. And we also have to remove it from the response.
cc @da2ce7
If you upload a torrent file, it calculates the right info-hash, but when you download the torrent file, the torrent has a different info-hash.
You can try with this torrent:
torrent-without-private-field.txt.zip
{ "created by": "imdl/0.1.13", "creation date": 1694545594, "encoding": "UTF-8", "info": { "length": 30, "name": "torrent-without-private-field.txt", "piece length": 16384, "pieces": "<hex>87 F9 9A 42 68 8D AE 18 E5 72 1D 7C 37 7B 88 91 E0 2D 08 9E</hex>" } }The downloaded version is:
downloaded-torrent-without-private-field.txt.zip
{ "announce": "udp://localhost:6969", "announce-list": [ [ "udp://localhost:6969" ] ], "info": { "length": 30, "name": "torrent-without-private-field.txt", "piece length": 16384, "pieces": "<hex>87 F9 9A 42 68 8D AE 18 E5 72 1D 7C 37 7B 88 91 E0 2D 08 9E</hex>", "private": 0 } }I think the problem is we always include the
privatefield in theinfodictionary even if the field was not present in the original torrent.I think we have to set the field
torrust_torrents::privatecolumn in the database toNULLwhen the original torrent does not include that field instead of setting the value to false. And we also have to remove it from the response.cc @da2ce7