Skip to content

Give upload temp files a fixed-length name - #44

Merged
rangoDJ merged 2 commits into
mainfrom
fix/upload-long-filenames
Oct 7, 2026
Merged

rangoDJ merged 2 commits into
mainfrom
fix/upload-long-filenames

Conversation

@rangoDJ

@rangoDJ rangoDJ commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Fixes #43

What changed

save_uploaded_file() writes to .upload-{uuid}.part instead of .{filename}.{uuid}.part, so the temp name no longer grows with the upload's name. The rest (write to temp, then atomic replace; cleanup on failure) is unchanged.

Testing

  • pytest: 227 passed, 4 skipped. New tests: a 224-byte UTF-8 name and a 254-character name upload, no temp file is left behind, an existing file is only replaced with overwrite. The 254-character case skips on Windows, where the test's temp directory hits the 260-character path limit (not an app concern: the container is Linux).
  • On Linux (WSL, Python 3.14), the real save_uploaded_file() with FastAPI/aiofiles stubbed: the original fails both long names with OSError: [Errno 36] File name too long; the fix uploads them with no temp files left.
  • Not tested in a running container.

🤖 Generated with Claude Code

rangoDJ and others added 2 commits October 7, 2026 16:43
Uploads were written to ".{filename}.{32 hex}.part" first, which adds 39
bytes to the name, so a valid name over ~216 bytes went past the 255-byte
filename limit and the upload failed with a server error.

Fixes #43

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ames

# Conflicts:
#	tests/test_file_manager.py
@rangoDJ
rangoDJ merged commit de78c43 into main Oct 7, 2026
4 checks passed
@rangoDJ
rangoDJ deleted the fix/upload-long-filenames branch October 7, 2026 22:09
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.

Uploading a file with a long name fails with a server error

1 participant