Files
MoviePilot/app/modules/filemanager
Huyvux12 2b4740bae3 fix(filemanager): keep partial filename within NAME_MAX for long dest names (#7574)
* fix(filemanager): keep partial filename within NAME_MAX for long dest names

_partial_path() appended '.' + uuid32 + '.mp-partial' to the full dest
name, so a valid 218-byte dest produced a 263-byte temp name and
_write_atomically() failed with ENAMETOOLONG. Budget the temp name
against PC_NAME_MAX (fallback 255): keep short names byte-identical,
truncate long dest names at UTF-8 char boundaries (os.fsencode, so
non-UTF-8 names round-trip), and shrink the uuid token when NAME_MAX
is abnormally small. Same directory, hidden prefix, uniqueness and
atomic replace semantics are unchanged.

Fixes #7572

* fix(filemanager): harden partial filename budgeting and fix lint gates

- Guard _resolve_name_max against missing os.pathconf on Windows and indeterminate <=0 POSIX limits
- Avoid double-dot prefix when multibyte leading char exceeds a tiny remaining budget
- Retry fsproxy.copy once with compact temp name when mount enforces stricter limit than PC_NAME_MAX
- Reuse bounded hidden temp naming for dangling symlink atomic repair in softlink()
- Fix pylint E0611 schema import, ruff F541 diagnostic, and APFS raw-byte test portability

---------

Co-authored-by: jxxghp <jxxghp@gmail.com>
2026-11-24 12:37:20 +08:00
..