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: can not download invalid utf8 named torrent #915

Merged

Conversation

evrins
Copy link
Contributor

@evrins evrins commented Mar 18, 2024

running on macOS sonoma 14.4 with M2 pro 

I found some magnet with invalid utf8 name fail to download with this library. but meanwhile qbitorrent handle it well.
Maybe we should use BestName function in metainfo.Info and BestPath function in metainfo.FileInfo which may return
human readable name in utf8 to successfully download this kind torrent.

before this patch invalid torrent will produce error message like this.

(base) ➜  Downloads torrent download 'magnet:?xt=urn:btih:0a5e2cbebf846baffd106bc01855bec11f6bd4e9'
361µs: getting torrent info for "infohash:0a5e2cbebf846baffd106bc01855bec11f6bd4e9"
9.145690083s: downloading "仙剑奇侠传三1080P": 0 B/72 GB, 0/4262 pieces completed (0 partial): 0 B/s
...
45.145761083s: downloading "仙剑奇侠传三1080P": 0 B/72 GB, 0/4262 pieces completed (0 partial): 0 B/s
[2024-03-18 09:52:15 +0800 ERR main client github.com/anacrolix/torrent peer.go:713]
  *torrent.PeerConn 0x1400129a008: writing received chunk 2047: open ?ɽ?????????1080P/?ɽ?????????01.mkv: no such file or directory

after this patch this torrent is successfully downloaded as 仙剑奇侠传三1080P

 torrent download 'magnet:?xt=urn:btih:0a5e2cbebf846baffd106bc01855bec11f6bd4e9'
49.792µs: getting torrent info for "infohash:0a5e2cbebf846baffd106bc01855bec11f6bd4e9"
5m6.973484417s: downloading "仙剑奇侠传三1080P": 0 B/72 GB, 0/4262 pieces completed (0 partial): 0 B/s
...
5m36.973856542s: downloading "仙剑奇侠传三1080P": 131 kB/72 GB, 0/4262 pieces completed (3 partial): 44 kB/s
5m39.974298875s: downloading "仙剑奇侠传三1080P": 524 kB/72 GB, 0/4262 pieces completed (4 partial): 131 kB/s

@anacrolix
Copy link
Owner

You might find this interesting BiglySoftware/BiglyBT#1274

@anacrolix anacrolix merged commit e6be81d into anacrolix:master Mar 18, 2024
9 of 10 checks passed
@evrins evrins deleted the fix_fail_to_download_invalid_utf8_named branch March 18, 2024 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants