Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving duplicates my Folder reference #76021

Closed
walidsantos opened this issue Apr 13, 2023 · 9 comments · Fixed by #90280
Closed

Saving duplicates my Folder reference #76021

walidsantos opened this issue Apr 13, 2023 · 9 comments · Fixed by #90280

Comments

@walidsantos
Copy link

walidsantos commented Apr 13, 2023

Godot version

4.0.2 (latest)

System information

Windows 10, Intel(R)HD Graphics Family, 20.19.15.5171, GLES3

Issue description

If i save my scene the folder duplicates ,i think there is bug on editor. Because i checked my game files if it really duplicates the folder . But it didn't.

2023-04-13.17-51-20.mp4

Steps to reproduce

Crtl + S
Also when deleting the folder all duplicated folders is deleted too.

Minimal reproduction project

N/A

@walidsantos walidsantos changed the title Saving bug Saving duplicates my Folders Apr 13, 2023
@walidsantos walidsantos changed the title Saving duplicates my Folders Saving duplicates my Folder reference Apr 13, 2023
@daredloco
Copy link

daredloco commented Apr 13, 2023

I can reproduce this problem, it seems to happen if the folder name is uppercase, it would then create an exact copy of the folder in lowercase. It wont happen if the folder name is all lowercase.

OS: Windows 10, Vulkan
Version: v4.0.2.stable.mono.official [7a0977c]

Edit: I did try to reproduce it again, but i could not. I did try to create another file inside another folder with uppercase letters, but it did work just fine. This did never happen before while using lowercase foldernames and only uppercase script names.
When the problem did happen, I was creating the folder from within Godot: New -> Script -> Select Folder -> Create New Folder.
Will try to reproduce this again.

@KoBeWi
Copy link
Member

KoBeWi commented Apr 13, 2023

I think this can happen when you create a script, but the path you provide for the script does not match the name casing of the folders (e.g. you have Scripts folder, but your script path is res://scripts/script.gd). Restarting the editor should fix it.

@KoBeWi
Copy link
Member

KoBeWi commented May 22, 2023

Yeah I just tested and it's the case. The editor should either fix path input casing or don't allow using wrong path.

@jamesfoxbr
Copy link

The problem disappear after I moved one of the files from one of the folders to the other. The only file did not was duplicated between folders

@AirDinghy
Copy link

I am still seeing this problem in 4.2.1
Was there anyway to figure out what file is causing the issue?

@TheSofox
Copy link
Contributor

TheSofox commented Apr 2, 2024

Okay, so the repo steps are:

  1. Create a folder, and create a scene in that folder.
  2. Save scene
  3. Delete Folder, push through the warning dialog.
  4. Create a new folder with the same name BUT DIFFERENT CASE to the previous folder in the same location.
  5. Save the scene again

Expected: Either you're given a warning that the original location doesn't exist, or the scene gets saved to the new folder with the same name even thought it has a different case (ie. NewFolder/NEWFOLDER/newfolder/etc.)

Actual: You now have two folders with the same name but different case in the Godot filesystem. Both folders seem to have the same contents.

I've tracked the core problem to editor\editor_node.cpp

In EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) unders case FILE_SAVE_SCENE when a scene is saved, they check if the directory exists. This check is case insensitive, so it may appear that the folder that the Scene "remembers" being in still exists, however the the folders the Scene remembers may have a different case, and somehow this pops up later down the chain when the Scene is saved.

@TheSofox
Copy link
Contributor

TheSofox commented Apr 5, 2024

I think I've narrowed the problem down to bool EditorFileSystem::_find_file in editor\editor_file_system.cpp specifically a line of code that goes if (fs->get_subdir(j)->get_name() == path[i])

@TheSofox
Copy link
Contributor

TheSofox commented Apr 5, 2024

I found a much easier way to duplicate this. Instead of deleting and making folders, you simply rename the folder that the resource is in in your OS File Manager (OS being Windows or Mac, as this issue isn't in Linux) and save the file again in the editor.

I've found a way to prevent the folders from being duplicated, so fixing this specific bug, but I've observed a related problem.

While I've ensured that the folder isn't duplicated, the open scene and open scripts still have their location set to be a slightly different place. After renaming the folder, you can then open up the same file and instead of it recognising its already open, it just opens it up again. This means you can have the exact same resource opened up multiple times:

image
image

@TheSofox
Copy link
Contributor

TheSofox commented Apr 5, 2024

Okay, I've created a PR to deal with the specific bug listed in this report; namely duplicated folders.

More widespread handling of Godot case should be a separate bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants