Fix file disappearing when renaming dependencies #86177
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #86174
When renaming a file, the editor will try to fix dependencies, but it will save affected scenes before that. However as a result of saving, the dependency might get removed thus a rename is performed on a dependency that no longer exists.
Then there is rename method that creates a
.depren
file after renaming dependency. However it treats "no rename" as successgodot/scene/resources/resource_format_text.cpp
Lines 921 to 924 in f8a2a91
meaning the file is not created, but the code continues normally. This results in a disaster.
The fix checks whether
.depren
file actually exists before removing the old file. Another option would be making the rename method return an error if the dependency can't be found, but I'm not sure if it's always expected to exist (in case of the fixed issue it didn't, but maybe it's expected to fail, idk).I modified the binary format too, but I didn't test if the same bug occurs. Better to be safe anyway.
This was probably regression from #81725 or #81657