-
Notifications
You must be signed in to change notification settings - Fork 257
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
Fanbox: Filename is too long, image is saved into pixivutil directory #525
Comments
Ah yeah, the attempted filename/path length came out to 403 characters in that, where the limit is 255 on all common modern filesystems. Same thing happened on a booru downloader I used to follow, if someone used a TAG variable and there were like 20-30 tags for the image. They implemented a hard character limit on all filenames. So probably something like |
Four filename extension characters and one for separator.10 окт. 2019 г. 3:05 ПП пользователь photon <notifications@github.com> написал:Ah yeah, the attempted filename/path length came out to 403 characters in that, where the limit is 255 on all common modern filesystems.
Same thing happened on a booru downloader I used to follow, if someone used a TAG variable and there were like 20-30 tags for the image. They implemented a hard character limit on all filenames.
So probably something like 250 (for buffer) - = max output length of the 3 filename format variables would solve this, as well as others that could come up without using %title%.
—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or unsubscribe.
|
Sure, meant the whole path+filename+ext as the "output" in my example. Not sure what you mean by 1 char for separator; filenames might have different numbers of separations (e.g. space) depending on the number of format variables, and in the case of %tags% would depend on the number of tags in the image....so I assume that is already done on the fly to some extent and a hard trancate to x if filename length > 250 or IOError36 would be the easiest sort of thing to do. I doubt it comes up often enough to make it worth doing conditionals on what tags to include if errored. But of course Nandaka will know the semantic details of filename/variable interaction much better than me x3 I just was giving this a bump with basic thoughts because I was testing a related filename error ^^ |
Ah, I misunderstood. Either way, there need to cut "The templader name" - path -.jpeg Except it's single byte on Linux and Unicode symbol on Windows, so it takes a bit more bits for same name in Linux than in Windows. It's a mess, honestly. |
It is already cut the filename to 255 in Line 113 in 9db6153
Should be counted as 193 chars, right? unless in linux, it is counted as double width chars for the kanji/kana. Related call Line 71 in 9db6153
|
FYI: For Windows, usually, 255 CHARS is maximum for FULLPATH. For Linux, 255 BYTES is the maximum for FILENAME. |
shouldn't be the other way around if linux limitation is based on bytes? e.g. assuming worst case scenario (3bytes per character), then the max filename character will be 255/3, isn't it? |
In worst case, there's char that represented by 4bytes but rarely. I come up with this code (didn't tested yet). if platform.system() == 'Linux':
# Linux: cut filename <= 255 bytes
dirname, basename = os.path.split(name)
while len(basename.encode('utf-8')) > 255:
filename, extname = os.path.splitext(basename)
filename[:len(filename) - 1]
basename = filename + extname
name = dirname + os.sep + basename
else:
# cut path to 255 char
if len(name) > 255:
newLen = 250
name = name[:newLen] |
Cutting filename to <= 249 bytes in UTF8 on Linux environment. For fixing Nandaka#525 For Linux, 255 bytes is the maximum for filename (not full path). And almost all Linux environments use UTF-8 for path encoding. And the path is used later with suffix ".pixiv" (consume 6 bytes). So 249 bytes is maybe a minimum. https://github.com/Nandaka/PixivUtil2/blob/dbb810716c4824724c03ce8e022a5b5d31f41800/PixivHelper.py#L590 Windows/Mac isn't affected.
…617) Cutting filename to <= 249 bytes in UTF8 on Linux environment. For fixing #525 For Linux, 255 bytes is the maximum for filename (not full path). And almost all Linux environments use UTF-8 for path encoding. And the path is used later with suffix ".pixiv" (consume 6 bytes). So 249 bytes is maybe a minimum. https://github.com/Nandaka/PixivUtil2/blob/dbb810716c4824724c03ce8e022a5b5d31f41800/PixivHelper.py#L590 Windows/Mac isn't affected.
…andaka#617) Cutting filename to <= 249 bytes in UTF8 on Linux environment. For fixing Nandaka#525 For Linux, 255 bytes is the maximum for filename (not full path). And almost all Linux environments use UTF-8 for path encoding. And the path is used later with suffix ".pixiv" (consume 6 bytes). So 249 bytes is maybe a minimum. https://github.com/Nandaka/PixivUtil2/blob/dbb810716c4824724c03ce8e022a5b5d31f41800/PixivHelper.py#L590 Windows/Mac isn't affected.
Prerequisites
Description
On linux, trying to download work with
Files from fanbox are saved into pixivutil folder instead of artist folder
Artist put excessively long title:
I expect that file gets saved into correct folder, possibly without title or with trunkated filename.
Versions
Current git, reported as 20190907b
The text was updated successfully, but these errors were encountered: