Skip to content

Fix long filename handling for byte-based filesystem limits#324

Open
LiuqingDu wants to merge 1 commit into
glomatico:mainfrom
LiuqingDu:codex-fix-long-filename-paths
Open

Fix long filename handling for byte-based filesystem limits#324
LiuqingDu wants to merge 1 commit into
glomatico:mainfrom
LiuqingDu:codex-fix-long-filename-paths

Conversation

@LiuqingDu

@LiuqingDu LiuqingDu commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes OSError: [Errno 36] File name too long when generated output filenames exceed the filesystem byte limit.

The issue is more likely with CJK titles because filename limits are byte-based, not character-based. For example:

2-01 Medley_ 前程锦绣 _ 喜气洋洋 _ 甜蜜如软糖 _ 流非飞 _ 不羁的风 (Live).m4a

The ASCII characters are mostly 1 byte each, while each Chinese character is usually 3 bytes in UTF-8. So a filename can be under 255 visible characters but still exceed the common 255-byte filename limit.

This is not limited to Chinese. Any filename containing many non-ASCII characters can hit this issue, including Japanese, Korean, emoji, and other writing systems. The filename may look shorter than 255 visible characters, but still exceed the filesystem's byte-based limit because UTF-8 encodes many of these characters as multiple bytes.

Changes

gamdl/downloader/base.py

  • Caps each generated path component at 255 UTF-8 bytes.
  • Applies --truncate as a smaller byte limit when provided.
  • Counts the file extension inside the filename byte budget.

gamdl/cli/cli.py

  • Stops writing download entries to the database after unexpected download errors.

gamdl/cli/database.py

  • Treats unstatable historical database paths as missing, so old bad entries do not crash future runs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant