Skip to content

fix(server): stop the chat upload name search when the path cannot be created - #459

Merged
BaaRai merged 2 commits into
BaaRai:mainfrom
Coff0xc:fix/upload-name-loop
Nov 22, 2026
Merged

BaaRai merged 2 commits into
BaaRai:mainfrom
Coff0xc:fix/upload-name-loop

Conversation

@Coff0xc

@Coff0xc Coff0xc commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Problem

Chat upload picks name, then name-1, name-2, and so on. The loop treated any Stat error other than "not exist" as "this name is taken". A component the filesystem rejects never becomes "not exist", so the request spun and grew the candidate name without bound.

Behavior

A Stat error other than "not exist" is returned to the client as a save failure. The search also stops after 10000 existing suffixes. A free name is unchanged: the first missing path is still the one written.

Tests

go test ./server/ -run TestUniqueUploadPath passes. It covers a double collision (note.txt and note-1.txt yield note-2.txt) and a 300-character component that must return an error.

… created

uniqueUploadPath treated every Stat error except "not exist" as "try the next
suffix". A name the filesystem rejects never becomes "not exist", so the
handler looped. The search now returns that error, and it also stops after
10000 existing suffixes.
Copilot AI balanced review requested due to automatic review settings November 21, 2026 19:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@BaaRai
BaaRai merged commit 83b35f8 into BaaRai:main Nov 22, 2026
5 checks passed
@BaaRai

BaaRai commented Nov 22, 2026

Copy link
Copy Markdown
Owner

Thanks @Coff0xc, merged. The upload name search now stops on a non-ENOENT error or after 10000 collisions instead of looping, and the merge commit only brings the branch onto main.

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.

3 participants