Skip to content

fix: cap path components at the filesystem byte limit - #1

Merged
spbkaizo merged 1 commit into
mainfrom
fix/long-filename-truncation
Jul 17, 2026
Merged

fix: cap path components at the filesystem byte limit#1
spbkaizo merged 1 commit into
mainfrom
fix/long-filename-truncation

Conversation

@spbkaizo

Copy link
Copy Markdown
Owner

Problem

Album and track names came from Tidal untouched except for illegal characters, so a release whose title runs to hundreds of bytes produced a path component over the 255-byte limit APFS/ext4/NTFS enforce — the download failed with file name too long. Heavily decorated titles (combining marks, CJK, emoji) hit this while looking short, since they run several bytes per rune.

Triggered by a real download: a 100 gecs release whose album directory name alone was 475 bytes.

Fix

  • Cap components at 200 bytes, truncating on a rune boundary so a multi-byte rune is never split.
  • The 55 bytes of headroom cover suffixes the download path appends to a sanitized base (.raw.flac, os.CreateTemp's .dl-<random>).
  • internal/tidal and internal/convert each carried an identical copy of sanitize; both now call a shared internal/fsname so the limit is defined once.

Tests

internal/fsname covers the long-unicode case, mid-rune truncation, the suffix budget against the real 255-byte limit, and that short names pass through unchanged. Full suite passes.

🤖 Generated with Claude Code

Album and track names came from Tidal untouched except for illegal
characters, so a release whose title runs to hundreds of bytes produced a
path component over the 255-byte limit APFS/ext4/NTFS enforce, and the
download failed with "file name too long". Heavily decorated titles hit
this while looking short: combining marks and CJK run several bytes per
rune.

Cap components at 200 bytes, truncating on a rune boundary so a
multi-byte rune is never split. The 55 bytes of headroom cover the
suffixes the download path appends to a sanitized base (".raw.flac",
os.CreateTemp's ".dl-<random>").

internal/tidal and internal/convert each carried an identical copy of
sanitize; both now call a shared internal/fsname so the limit is defined
once.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@spbkaizo
spbkaizo merged commit 1388e7e into main Jul 17, 2026
1 check passed
@spbkaizo
spbkaizo deleted the fix/long-filename-truncation branch July 17, 2026 15:10
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