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
Directoryinstance:res://fooin oneDirectoryobject, then deleteres://fooin anotherDirectoryobject. The first no longer is “open” to a valid directory.openverify that the path is still valid before each action?The new behavior is correct, the previous one was quite dangerous.
Directoryauto-opensres://when it’s instantiated, so if you did:It would remove the
res://testfolder, and this is unexpected for many users as the implementation detail ofDirectorystarting 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 theDirectoryconfigured for access to theuser://filesystem), and then you can remove anything you want inuser://.