Improve determinism of UIDs#111858
Conversation
|
This feels unsafe, this will make I'm not sure this "fixes" anything and just helps in cases where users violate best practices as documented etc. |
Do people keep multiple files where only casing is different? Yes, this can happen, it sounds unlikely, even if it's technically allowed in case-sensitive filesystems. Either way, the UID system is able to deal with collisions, so no duplicate UID will be created. |
|
I'd say it's about as likely or as reasonable as mixing casing across platforms/users in a shared project |
|
@AThousandShips this is addressing a report Godot users that are making games are having, the having two files: |
|
I didn't refute it happening, but the fact remains that the error comes from breaking best practices, which I think should at least be considered hence bringing it up |
|
unfortunately, windows will some times make it seem like you renamed the file but you actually didn't, so users think they are submitting files with the correct casing and it is not how they are stored internally. You can of course notice this in GitHub before pushing a change, but an artist working on a game might not :( |
|
That casing difference will cause other bugs though and issues with git, hence not best practices But if the UID system handles conflicts then I guess it'd be safe to account for this incorrect usage, and hopefully things won't be more confusing for such users more if the UID system is more lenient (Also, no need to tag when I'm right in the conversation, it just sounds like you're calling me out rather than just bringing to my attention) |
|
sorry for the tag, rocketchat ptsd from people not getting notified 😅 |
|
That is very relatable! The internet is a weird place with the extremes of Facebook with the worst tags, and RC of never getting the tags you're actually interested in |
There was a problem hiding this comment.
I think we can safely go ahead with this, but I think it's only a band-aid for a more serious problem of the editor not helping users to follow proper best practices, I'd say a more proper solution to prevent these issues would involve:
Warning, or even throwing an error, when renaming a file just changing the casing on a case-insensitive OS, something like "cannot rename file on a case-insensitive system, file will not be moved", alternatively adding some system on these OSes to move a file properly by moving to a temporary and then moving backRealized this has actually been fixed already- Warning on case-sensitive systems when renaming in the same way, saying that "these changes will have no effect when running on a case-insensitive operating system" or similar to warn that renaming them and updating VCS won't work on those OSes and will be confusing
- More proactive detection in the editor for case errors, like in
load("res://foo/bar.gd)if there is a fileres://Foo/bar.gd, not just when running but as a warning in the editor
Edit: Opened a proposal for usability improvements with respect to casing
Retracting approval until this has been confirmed to fix existing bugs, as opposed to hypothetical issues
|
Just to confirm: this does not cause any already assigned UIDs to be changed, i.e. for any files with |
|
No, it's only for new UIDs. |
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Tested locally on Linux (case-sensitive btrfs filesystem), it doesn't seem to work on my end:
$ cat touch.gd.uid TOUCH.gd.uid
uid://bxr365upoga6i
uid://b320arqlsxif0
Both files have the same content:
extends CanvasLayer
func _ready() -> void:
hide()
if DisplayServer.is_touchscreen_available():
show()I've removed both .uid files beforehand to force them to be regenerated.
I believe that is intended? to test this you would have to generate one, and then remove it and try with the other one. Kobewi said that there is already a failsafe to generate a new code if the current one exists |
|
Yes, you can test it like this:
The UID should be the same for both files. |
That makes sense. I've tested it again following these steps, and it works as expected. |
bruvzg
left a comment
There was a problem hiding this comment.
Makes sense. Cases with two files that are only different in the name case are non-portable, and should be avoided regardless of this change.
akien-mga
left a comment
There was a problem hiding this comment.
I think this makes sense, this is a common source of issue for cross-platform teams that leads to UID regeneration churn and diff noise.
|
Thanks! |
|
For the record, another scenario where this PR is good: Programs which switch the case of extensions between lower or upper case (ex: |
|
Cherry-picked for 4.5.2. |
Improve determinism of UIDs
This makes path-based UID generation case-insensitive, which improves consistency on case-insensitive systems. For example if 2 people generate UID for a file, but the file has different casing on each side (just Windows things), the UID will be the same.
Also fixes UID not being deterministic when duplicating files (regression (?) from #106763).