godot: Directory must be open before using remove (3.2.3 rc1)
Godot version: 3.2.3 rc1
OS/device including version: macOS 10.15.5
Issue description:
As of 3.2.3 rc1 you must open a directory before using remove
. Prior to 3.2.3 rc1 you didn’t have to open up a directory to delete it, which makes sense. If you are attempting to delete a directory, then you probably don’t care if it doesn’t exist. If you did, you’ d check for it first. The new functionality might be the “right” way but I would argue it is a breaking change and shouldn’t be introduced in a patch.
Steps to reproduce:
Assuming a directory user://foo
exists and it is empty.
var d = Directory.new()
d.remove('user://foo') # this causes error, the directory is not removed. this works in 3.2.2
Minimal reproduction project: See code. Should be enough.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (12 by maintainers)
Your PR isn’t complicated, but the repercussions of it are. Should a
Directory
instance:res://foo
in oneDirectory
object, then deleteres://foo
in anotherDirectory
object. The first no longer is “open” to a valid directory.open
verify that the path is still valid before each action?The new behavior is correct, the previous one was quite dangerous.
Directory
auto-opensres://
when it’s instantiated, so if you did:It would remove the
res://test
folder, and this is unexpected for many users as the implementation detail ofDirectory
starting inres://
by default is not known to all.If you want to delete a folder in e.g.
user://
, you should openuser://
(and thus have theDirectory
configured for access to theuser://
filesystem), and then you can remove anything you want inuser://
.