Skip to content

Comments

[options] add --truncate-filenames to trim paths#9079

Open
NecRaul wants to merge 4 commits intomikf:masterfrom
NecRaul:args/truncate-filenames
Open

[options] add --truncate-filenames to trim paths#9079
NecRaul wants to merge 4 commits intomikf:masterfrom
NecRaul:args/truncate-filenames

Conversation

@NecRaul
Copy link
Contributor

@NecRaul NecRaul commented Feb 17, 2026

This PR introduces a new --truncate-filenames option to automatically truncate filenames so that destination paths stay within OS path-length limits. PathFormat now applies truncation when building filenames and .part files, ensuring compatibility across Windows and POSIX systems.

Changes

  • Add --truncate-filenames CLI argument
  • Read truncate-filenames from the config with default False
  • Update PathFormat.build_path and part_enable to apply truncation
  • Implement _truncate_filename to respect path and name length limits, using os.pathconf on POSIX and fixed limits on Windows

Notes

_truncate_filename currently uses character counts via len(), which may differ from filesystem byte limits for multibyte filenames. Future improvements could make truncation byte-aware for full UTF-8/UTF-16 safety.

Introduce a new --truncate-filenames option to automatically truncate
filenames so that the resulting paths stay within OS path-length limits.
PathFormat now checks this option when building filenames and .part
files, calling _truncate_filename with the directory, filename,
extension, and optional suffix.

- Add --truncate-filenames CLI flag using ConfigConstAction
- Read "truncate-filenames" from config with default False
- Update PathFormat.build_path and part_enable to apply truncation
- Implement _truncate_filename for Windows and POSIX
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