[server] .tmp avatar file leaks on disk if fs::rename fails #31
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
File
solitaire_server/src/auth.rslines 392–393Description
upload_avatarwrites to<user_id>.<ext>.tmpthen renames to<user_id>.<ext>. Ifrenamefails (cross-device move, permission error), the function returns an error and the.tmpfile remains on disk permanently. The server has no periodic cleanup, unlike the client which callscleanup_orphaned_tmp_files()at startup. Repeated failed uploads accumulate stale tmp files and leak disk space.Fix
In the error branch after a failed rename, add
let _ = std::fs::remove_file(&tmp_path);to clean up the temp file.