The rename server behavior will not overwrite, it will only rename an existing file.
The code you referenced is part of the upload function. This is the code that handles the case where you are uploading a file where one with the same name already exists. It will either overwrite the original or it will append a value to the new file.