qbittorrent / qBittorrent

qBittorrent BitTorrent client
https://www.qbittorrent.org
Other
28.38k stars 3.99k forks source link

Some torrents with very long file names are not downloadable: "file name too long" #7038

Closed unam56 closed 1 year ago

unam56 commented 7 years ago

qBittorrent version: 3.3.13, 64 bit. OS: Ubuntu Linux 16.04. Qt version: 5.5.1. libtorrent version: 1.0.11.0. boost version: 1.58.0. PPA: http://ppa.launchpad.net/qbittorrent-team/qbittorrent-stable/ubuntu

Problem

qBitTorrent under Linux can't download files for most torrent files, created under OS Windows, because ext4 and ntfs have different maximum name length limit.

Expected behavior

Provide two modes:

Auto rename mode: rename files automatically; show list of auto renamed files in gui; allow user rerename files manually in gui.

Manual rename mode: if name too long, generate temp short name, continue download, show dialog to choose name manually by user, rename file, continue download.

Steps to reproduce

Current behavior

Expected behavior

Automatically map ntfs long names to ext4 short names.

Seeker2 commented 7 years ago

Related issues: https://github.com/qbittorrent/qBittorrent/issues/6645 can't handle too long file names https://github.com/qbittorrent/qBittorrent/issues/6690 Qbittorrent deletes dowloaded torrent instead of checking it Not really related, but another problem that can happen due to filenames: https://github.com/qbittorrent/qBittorrent/issues/5661 Multiple torrents with same name don't handle well

bathrobehero commented 5 years ago

Why is this still haven't fixed.

icemtel commented 4 years ago

I am also experiencing this on v4.2.1

Alanoll commented 4 years ago

Just curious if anyone has tried using the \\?\ path method. It seemed to fix my torrents when the path exceeded MAX_PATH.

UNC paths would be \\?\UNC\ServerName\Share instead of \\ServerName\Share Local paths would be \\?\C:\Path\To\Torrent\Folder instead of C:\Path\To\Torrent\Folder

I do have the Group Policy found here enabled: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#enable-long-paths-in-windows-10-version-1607-and-later

tsangwpx commented 4 years ago

Please note that the issue is on Linux. Wrong label was assigned. I am not sure whether the issue is fixed or not.

FYI, the filename limitations on the Linux is 255 bytes instead of characters. The maximum path length is 4096 bytes. The situation is worse when the filename contains multibyte characters (for example, CJK characters basically uses 3 bytes in UTF-8). The effective filename may be 100 characters long.

To solve the issue on Linux, a long name should be automatically renamed/mapped to a legal identifiable one with shorter length.

FranciscoPombal commented 4 years ago

This is a filesystem-level limitation common to all mainstream linux filesystems, so I would say it's out of scope for qBittorrent to try to work around that.

If someone creates a torrent where filenames are close to or exceed 255 ASCII characters or ~100 CJK characters, they did a bad job. Such torrents are not only a problem for qBittorrent, but for every other tool (like btcheck) in the ecosystem. So creating a workaround for this in qBittorrent is just a band-aid. The real fix would be to prevent torrent creator tools from creating files that are incompatible with mainstream filesystems (this includes qBittorrent built-in torrent creator, if it does this). Or go ask for ext5 with longer file names or something.

tsangwpx commented 4 years ago

After grep-ing for a while, the filename too long issue should be solved long time ago. The libtorrent author mentioned it. https://blog.libtorrent.org/2014/12/filenames/

On Linux, long filename is truncated around 240 bytes plus proper extension.

https://github.com/arvidn/libtorrent/blob/25a1f12991b4af1e133b966fae963168116306e9/src/torrent_info.cpp#L285

I confirmed this behavior with qBittorrent 4.1.5 on debian buster.

BTW, the Windows likely limits 255 character in UTF-16 and the conversion from UTF-16 to UTF-8 likely cause longer filename. The filename limits are unlikely changed in the future because it is not only defined in the filesystem but also in the Linux kernel headers. Yet, naming file with really long name isnt good.

a0193143 commented 2 years ago

I found this issue when I move from Windows to TrueNAS. I thought it was TrueNAS's problem that cause file missing, but after digging a while it was because the filename in torrent cutted. According to Libtorrent's source code, it would cut the file name to 240 bytes if there's extension. In my opnion this has to be "if the whole filename exceed 255 bytes then cut", my file is IN the directory (which whole filename is 243 bytes), but because it cutted and renamed, qb can't find my file. Hope this could be fixed.

ferenczy commented 1 year ago

I'm having the same problem, but at a different point, I would say. I'm not even able to start the downloading. If I understand the OP correctly, in his case, he's able to start the download of such a file and the error happens later, at some time during the downloading or when the download is finished (and the file is being copied from the temporary directory to the target location, I guess).

In my case, I'm not even able to start the download of the majority of files. When I click on "Download" in the file's context menu, nothing happens. When I click on "Open the download window", the Download window is not even opened, I get the error message immediately:

Failed to load the torrent: ... Error: File name too long

I have tried it now and it happened in 100% of cases (16 torrents).

I'm using qBittorrent 4.4.1 on Ubuntu 22.04.2.

ferenczy commented 1 year ago

Update: I have just found out, that it's happening only (so far) for a single specific torrent site - TorrentDownload.info (the search plugin TorrentDownload w. categories, version 2.2). So the issue may be with that search plugin or the site itself, I guess. Unfortunately, almost all search results that I'm interested in are coming from that site (roughly 95%).

I'll try to test it further.

ferenczy commented 1 year ago

OK, the problem solved! I'm sorry for the useless posts, but maybe it will help someone.

The issue is in the search plugin TorrentDownload w. categories, version 2.2. I have downgraded to the previous version TorrentDownload 1.0 and I'm able to download torrents even from the site TorrentDownload.info now. 🥳

I don't even know how are those categories supposed to work so I don't mind using the search plugin without them.

luzpaz commented 1 year ago

I'm using qBittorrent 4.4.1 on Ubuntu 22.04.2.

@ferenczy Current stable is 4.5.4
Can you make sure this is the case by installing the latest development version and using the v2.2 search plugin?
Test on the 4.6 beta from https://www.qbittorrent.org/download and report back?

luzpaz commented 1 year ago

bumping for activity

ferenczy commented 1 year ago

Sorry, I'm using what's in Ubuntu's repositories (Jammy) and that's currently 4.4.1-2. I'm not a big fan of AppImages for the lack of a central repository.

Anyway, I'll try it when I find some spare time.

luzpaz commented 1 year ago

@ferenczy we're really trying to close tickets. I'm closing this ticket for now. If you can reproduce on latest stable, please re-open it.

1298345095 commented 1 month ago

System: Unraid 6.12.10 When folder name is too long, error occurs. I try to rename folder name, but no effect.(Other normal folder name could be renamed.)