[options] add --truncate-filenames to trim paths#9079
Open
NecRaul wants to merge 4 commits intomikf:masterfrom
Open
[options] add --truncate-filenames to trim paths#9079NecRaul wants to merge 4 commits intomikf:masterfrom
NecRaul wants to merge 4 commits intomikf:masterfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a new
--truncate-filenamesoption to automatically truncate filenames so that destination paths stay within OS path-length limits.PathFormatnow applies truncation when building filenames and .part files, ensuring compatibility across Windows and POSIX systems.Changes
--truncate-filenamesCLI argumenttruncate-filenamesfrom the config with default FalsePathFormat.build_pathandpart_enableto apply truncation_truncate_filenameto respect path and name length limits, usingos.pathconfon POSIX and fixed limits on WindowsNotes
_truncate_filenamecurrently uses character counts vialen(), which may differ from filesystem byte limits for multibyte filenames. Future improvements could make truncation byte-aware for full UTF-8/UTF-16 safety.