Skip to content

Add disambiguator to chapter filenames to handle duplicate chapter names#2305

Merged
AntsyLich merged 30 commits intomihonapp:mainfrom
radian-software:bugfix/1395_different_chapters_with_same_name
Oct 7, 2025
Merged

Add disambiguator to chapter filenames to handle duplicate chapter names#2305
AntsyLich merged 30 commits intomihonapp:mainfrom
radian-software:bugfix/1395_different_chapters_with_same_name

Conversation

@raxod502
Copy link
Contributor

@raxod502 raxod502 commented Jul 24, 2025

This is #2206 in combination with fatotak#4 and fatotak#5. Please see the original PR description as well as #2206 (comment) and #2206 (comment) for further context; a brief summary of the changes follows:

  • Downloaded chapters use a filename with a truncated MD5 hash of the chapter URL, to prevent identically-named chapters from overwriting each other when downloaded.
  • Previously downloaded chapters, which do not include the hash, are still read by Mihon, but new chapters are saved with the new filename format.
  • Filenames of more than 240 bytes are disallowed; this was already the intention of the existing code, but due to a bug, longer filenames were sometimes allowed, leading to errors when those filenames were used to write to disk.
  • There is a new option in the advanced settings, which disallows non-English (non-ASCII) characters from being used in filenames. This should not be enabled except in cases where the user's storage medium is hopelessly broken and cannot be fixed to comply with international Unicode standards.
    • When enabled, all existing filename restrictions are still applied, and on top of that, any non-ASCII characters are replaced with their hexadecimal representations. This applies to source names, manga names, and chapter names.
    • Existing chapters downloaded before the user flips the setting (in either direction) can still be found by the app, unless the containing source or manga directory names contained non-ASCII characters as well. The latter exception is because we don't currently have a way for Mihon to check multiple possible source or manga directory names, but we do have a way for it to check multiple possible chapter filenames, which I used.
    • This setting bans ALL non-English characters, making foreign-language titles unreadable. If this is undesirable to the user, they can provide more detailed and verifiable information about what characters do and don't work on their device, so that we can adjust the setting to be more fine-grained - however at present no user has provided this information so we can't implement anything better.

Resolves #1395.
Resolves #2280.
Resolves #1633.
Resolves #1517.

Downloaded chapter before this change:

./コミックグロウル (ALL)/王太子の婚約者はもう耐えられない!/BUSHIROAD WORKS_(前編).cbz

Downloaded chapter after this change:

./コミックグロウル (ALL)/王太子の婚約者はもう耐えられない!/BUSHIROAD WORKS_(前編)_214cd0.cbz

Downloaded chapter after this change, with the setting enabled to disallow non-English characters in filenames:

./e382b3e3839fe38383e382afe382b0e383ade382a6e383ab (ALL)/e78e8be5a4aae5ad90e381aee5a99ae7b484e88085e381afe38282e38186e88090e38188e38289e3828ce381aae38184efbc81/BUSHIROAD WORKS_(e5898de7b7a8)_214cd0.cbz

Please see also mihonapp/website#161, which adds documentation as was requested by @Foffs on Discord.

See also #2332, which improves the behavior of LocalSource with less readable filenames.

jhskim and others added 10 commits June 17, 2025 00:00
Fixed: new downloads.
Working: reading.
Todo: migrate old chapters to new name + delete and force redownload of problem chapters (chapters within a manga where name and scanlator are the same value).
…d is more appropriate for new file naming format.
…ent_chapters_with_same_name

Improvements to PR#2206
@@ -165,24 +196,30 @@ class DownloadProvider(
}

fun isChapterDirNameChanged(oldChapter: Chapter, newChapter: Chapter): Boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I think about it this function doesn't really account for name schema change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you like me to make changes to it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible. Feel free to make this it's own PR so we can ship it separately than this feature.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this accounted for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You said it could be a separate PR, so changes to it aren't included here.

@@ -165,24 +196,30 @@ class DownloadProvider(
}

fun isChapterDirNameChanged(oldChapter: Chapter, newChapter: Chapter): Boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible. Feel free to make this it's own PR so we can ship it separately than this feature.

@raxod502 raxod502 requested a review from MajorTanya August 2, 2025 22:24
Copy link
Member

@MajorTanya MajorTanya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned in the non-English vs non-ASCII comment, I strongly prefer going with non-ASCII but I refrained from making change suggestions everywhere. Seemed excessive to me to post like, 20 suggestions when it's effectively what, like 3 standard refactor -> rename operations in an editor/IDE.

Otherwise just a few things that stood out to me from reading the code. Excellent work.

raxod502 and others added 3 commits August 3, 2025 18:10
…ovider.kt

Co-authored-by: MajorTanya <39014446+MajorTanya@users.noreply.github.com>
@raxod502 raxod502 requested a review from MajorTanya August 4, 2025 01:24
Copy link
Member

@MajorTanya MajorTanya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My points are resolved, I have nothing else to say currently

Not sure what the others think though.

@AntsyLich AntsyLich added this to the v0.20.0 milestone Aug 6, 2025
@raxod502
Copy link
Contributor Author

raxod502 commented Aug 6, 2025

Added changelog entry

@@ -165,24 +196,30 @@ class DownloadProvider(
}

fun isChapterDirNameChanged(oldChapter: Chapter, newChapter: Chapter): Boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this accounted for?

raxod502 and others added 3 commits October 5, 2025 09:07
@raxod502 raxod502 requested a review from AntsyLich October 5, 2025 16:36
raxod502 and others added 3 commits October 7, 2025 15:28
Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
@raxod502 raxod502 requested a review from AntsyLich October 7, 2025 22:31
@AntsyLich AntsyLich merged commit 58b25d6 into mihonapp:main Oct 7, 2025
1 check passed
@raxod502 raxod502 deleted the bugfix/1395_different_chapters_with_same_name branch October 8, 2025 00:37
@AntsyLich AntsyLich removed this from the v0.20.0 milestone Dec 1, 2025
cuong-tran pushed a commit to komikku-app/komikku that referenced this pull request Jan 14, 2026
…ionally for OSes that don't support Unicode in filename (mihonapp/mihon#2305)

Co-authored-by: jkim <jhskim@hotmail.com>
Co-authored-by: fatotak <111342761+fatotak@users.noreply.github.com>
Co-authored-by: MajorTanya <39014446+MajorTanya@users.noreply.github.com>
Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
(cherry picked from commit 58b25d697f7987e9888344e815d5646ec010a663)
cuong-tran pushed a commit to komikku-app/komikku that referenced this pull request Jan 14, 2026
…ionally for OSes that don't support Unicode in filename (mihonapp/mihon#2305)

Co-authored-by: jkim <jhskim@hotmail.com>
Co-authored-by: fatotak <111342761+fatotak@users.noreply.github.com>
Co-authored-by: MajorTanya <39014446+MajorTanya@users.noreply.github.com>
Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
(cherry picked from commit 58b25d697f7987e9888344e815d5646ec010a663)
Ramsesdb pushed a commit to Ramsesdb/gexu-legacy-fork that referenced this pull request Jan 19, 2026
…ionally for OSes that don't support Unicode in filename (mihonapp#2305)

Co-authored-by: jkim <jhskim@hotmail.com>
Co-authored-by: fatotak <111342761+fatotak@users.noreply.github.com>
Co-authored-by: MajorTanya <39014446+MajorTanya@users.noreply.github.com>
Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants