sopel-irc / sopel

:robot::speech_balloon: An easy-to-use and highly extensible IRC Bot framework. Formerly Willie.
https://sopel.chat
Other
950 stars 405 forks source link

config: Eliminate side-effect of `FilenameAttribute.parse()` #2466

Open dgw opened 1 year ago

dgw commented 1 year ago

It took me a while, but I got around to this:

Now that FilenameAttribute creating the file/directory it's set to has been shoved in my face, I'm not sure I like that behavior. I'll add that to my list of things to think about, and write up an issue if I still don't like it after investigating.

And we're still doing it:

https://github.com/sopel-irc/sopel/blob/9a5e84d9578710cda07e815a417102a92fcf3412/sopel/config/types.py#L742-L753

There are a couple of options that I know of:

Why?

If the file or directory specified in a FilenameAttribute already exists, permissions aren't checked. If the file or directory doesn't exist, it will be created and left empty just because Sopel parsed its settings. That seems silly.

Let's always validate permissions, if we're going to check them; and if not, deprecate the current behavior & encourage plugin developers to use EAFP.