You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I see below errors at the top of the page when I try to upload a book with Chinese title.
Failed to Move Cover File /media/[英]乔安·弗莱彻/埃及四千年(破解四千年王朝兴衰秘密的里程碑式巨作,BBC古埃及历史纪录片原著,《出版人周刊》《科克斯书评》《图书馆杂志》2016年度最佳图书,《华盛顿邮报》《卫报》等30家知名媒体联名推荐.)/cover.jpg: [Errno 36] File name too long: '/media/[英]乔安·弗莱彻/埃及四千年(破解四千年王朝兴衰秘密的里程碑式巨作,BBC古埃及历史纪录片原著,《出版人周刊》《科克斯书评》《图书馆杂志》2016年度最佳图书,《华盛顿邮报》《卫报》等30家知名媒体联名推荐.)/cover.jpg'
Rename title from: '/tmp/calibre_web/f55b36cf44482f28ec2c90c7b809715c' to '/media/[英]乔安·弗莱彻/埃及四千年(破解四千年王朝兴衰秘密的里程碑式巨作,BBC古埃及历史纪录片原著,《出版人周刊》《科克斯书评》《图书馆杂志》2016年度最佳图书,《华盛顿邮报》《卫报》等30家知名媒体联名推荐.) (12)' failed with error: [Errno 36] File name too long: '/media/[英]乔安·弗莱彻/埃及四千年(破解四千年王朝兴衰秘密的里程碑式巨作,BBC古埃及历史纪录片原著,《出版人周刊》《科克斯书评》《图书馆杂志》2016年度最佳图书,《华盛顿邮报》《卫报》等30家知名媒体联名推荐.) (12)'
If the title of a book is mostly consisted of Chinese characters, and the title is really long, the book will fail to upload due to the filename length limit from the file system.
For ext4 file system, the filename limit is 255 bytes according to https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits. Most linux users encode filenames with UTF-8 encoding, so a Chinese character results in 3 bytes. So the maximum title length allowed for a Chinese book is 255/3 = 85 characters (on ext4 and some other file systems).
I've found that 1e04b51 limites the filename to 96 characters. But that's not short enough. In the worst case, a character is encoded to 4 bytes (e.g. all characters encoded with UTF-32 or some characters encoded with UTF-8), that means the chars parameter of get_valid_filename should be set no larger than 255/4 = 63.
Furthermore, maybe it's a better idea to make it configurable to support other file systems with more strict limits.
BTW, I can import the book with calibredb on ext4 with no problem. Not sure how calibredb handles this case.
To Reproduce
Steps to reproduce the behavior:
Make sure the file system is ext4. (I use mac and I don't have a Linux machine. But ext4 is possible with Docker Desktop on macOS.)
Edit a random epub file with ebook-edit and update the title field of content.opf to a title with 120+ Chinese characters, then save it.
Upload the modifed file to calibre-web and you should be able to see the error messages.
Logfile
N/A
Expected behavior
No error messages and the file should be able to be uploaded.
Screenshots
N/A
Environment (please complete the following information):
Describe the bug/problem
I see below errors at the top of the page when I try to upload a book with Chinese title.
If the title of a book is mostly consisted of Chinese characters, and the title is really long, the book will fail to upload due to the filename length limit from the file system.
For ext4 file system, the filename limit is 255 bytes according to https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits. Most linux users encode filenames with UTF-8 encoding, so a Chinese character results in 3 bytes. So the maximum title length allowed for a Chinese book is 255/3 = 85 characters (on ext4 and some other file systems).
I've found that 1e04b51 limites the filename to 96 characters. But that's not short enough. In the worst case, a character is encoded to 4 bytes (e.g. all characters encoded with UTF-32 or some characters encoded with UTF-8), that means the
chars
parameter ofget_valid_filename
should be set no larger than 255/4 = 63.Furthermore, maybe it's a better idea to make it configurable to support other file systems with more strict limits.
BTW, I can import the book with calibredb on ext4 with no problem. Not sure how calibredb handles this case.
To Reproduce
Steps to reproduce the behavior:
Logfile
N/A
Expected behavior
No error messages and the file should be able to be uploaded.
Screenshots
N/A
Environment (please complete the following information):
Additional context
N/A
The text was updated successfully, but these errors were encountered: