Page MenuHome

File Browser unable to rename with Upper/Lower case
Confirmed, NormalPublicBUG

Description

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce GTX 1060 6GB/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 432.00

Blender Version
Broken: version: 2.83.5, branch: master, commit date: 2020-08-19 06:07, hash: rBc2b144df395f
version 2.90.0 as well.

Short description of error
When renaming a file/folder case changes are not taken into account.

Exact steps for others to reproduce the error
On default startup :
File -> Save As -> New Folder -> Type "TEst" as name, click to release focus.
Right Click -> Rename (or F2); Type "Test", click to release focus.
The name changes back to "TEst".
Workaround :
Rename to "Test 2", then back to "Test".

Event Timeline

Germano Cavalcante (mano-wii) changed the task status from Needs Triage to Confirmed.Thu, Sep 10, 11:14 PM
Germano Cavalcante (mano-wii) changed the subtype of this task from "Report" to "Bug".

I confirm the problem on Windows.
As far as I can see, checking for a file on Windows is case insensitive.
When the file "already exists", the rename operation is skipped.

I'm not sure if this condition is really necessary, but if so, this would solve the problem:

diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 7039eba7db1..3b52396ea8d 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -407,7 +407,9 @@ static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname)
   BLI_join_dirfile(newname, sizeof(newname), sfile->params->dir, filename);
 
   if (!STREQ(orgname, newname)) {
-    if (!BLI_exists(newname)) {
+    /* Make sure the filenames are different (case sensitive).
+     * Something similar is done in `BLI_rename`. */
+    if (!BLI_exists(newname) || BLI_strcaseeq(orgname, newname)) {
       errno = 0;
       if ((BLI_rename(orgname, newname) != 0) || !BLI_exists(newname)) {
         WM_reportf(RPT_ERROR, "Could not rename: %s", errno ? strerror(errno) : "unknown error");