-
Notifications
You must be signed in to change notification settings - Fork 0
Description
@samwaseda, I was reading DirectoryObject and because of how _protected is set at initialization and I have the following concern:
- I used the class to make a directory and save something there, this triggering protection
- Later, I come back and accidentally reinstantiate a new
DirectoryObjectat the same path - If I shut down my interpreter or kill the new DO in any way, it deletes the folder
Is that correct? I know our current use case involves the path being automatically generated, so we presumably only get the same DO in the same spot when we're loading on and thus get the old protected state back. However, that still feels fragile to guarantee -- we need to make sure we never instantiate a fresh one without loading-- and downright cruel to direct human users, who may simple provide and existing path.
A solution I see is to wrap _protected as a property and write a .do_protected file to the directory when it's set true, and remove the file when it's set to false. Then in the init, only use the default if there's no file lying around.
Or maybe make .protect() and .unprotect() methods or whatever. My point is only around protecting us against reinstantiating in existing locations and thus accidentally killing stuff.
I come around more and more to Jan's perspective that any deletion should default to false.