mihonapp / mihon

Free and open source manga reader for Android
Apache License 2.0
9.89k stars 449 forks source link

Can't view downloaded chapter, "File name too long" error #279

Open w4tchdoge opened 8 months ago

w4tchdoge commented 8 months ago

Steps to reproduce

  1. Enable "Save as CBZ archive"
  2. Download a chapter of a work which has a long title.
  3. Try and open the chapter.

Expected behavior

Chapter opens and I can view it.

Actual behavior

A toast notification pops up saying "File name too long".

Crash logs

No response

Mihon version

0.16.2

Android version

Android 14

Device

Samsung Galaxy Tab S8+

Other details

I had first experienced this issue in TachiyomiSY after a recent update where storage related settings were changed. When I asked about this in the tachiyomi-sy support channel I was advised to see if I could reproduce this behaviour on Mihon, which I was able to. The following text is the message I had sent in the tachiyomi-sy support channel after I was able to reproduce the issue in Mihon 0.16.2 (stable)


I can reproduce this in Mihon 0.16.2, but I had to move the folder containing the .cbz downloaded by SY to the Mihon local folder and try to open the local source I suspest this is because the external extension has different .cbz naming/foldering than the one built-in source SY has (extenal save the .cbz as {full gallery name}/Chapter.cbz while SY saves it as {full gallery name}/{gallery id}_{version}_{full gallery name}.cbz) if it helps, the {full gallery name} in this case is 225 characters long, including spaces

Acknowledgements

infyProductions commented 8 months ago

I tried to recreate this scenario to try long file names in both files and folders using local source to easily access the files in the file explorer.

Note:

Folder Test (255 chars):

File Test (253 chars for file name, 3 characters for the file extension making it 256 chars)

Additional notes:

w4tchdoge commented 8 months ago

Additional notes:

  • It requires testing for external storages (typically SD card) formatted in the common file systems (fat32 and exfat)

I will add that my TachiyomiSY folder is on an SD card, and that's also where I made my Mihon folder when I attempted to reproduce it on Mihon.

As I don't remember reformatting my 256 GB SD card to another file system, I believe it's an exFAT formatted SD card.

infyProductions commented 8 months ago

While I was researching the limits for the fat32 file system, I stumbled this from a MS website of all places.

image

Reference: https://learn.microsoft.com/en-us/windows/win32/fileio/filesystem-functionality-comparison#limits

TL;DR: the folder path must not exceed 255 characters.

Possible proposal(?): If the file and folder path (including file extensions) is too long, attempt to shorten the file name (around 250 chars) to include an underscore and the preferred file format something like this: <250 chars>_.png