1
0
Fork 0
mirror of synced 2024-07-03 05:21:02 +12:00

Don't mkdir defaultConfigDirectory if not needed

Check to see if config.json exists in the current working directory before creating a new configuration directory in the home folder.

If config.json exists, then defaultConfigDirectory would be empty and unused - so there's no reason to create that directory if it's not going to be used.
This commit is contained in:
ComradeEcho 2020-12-03 22:04:52 -06:00 committed by GitHub
parent 79078d8e0b
commit 39e31794db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -257,12 +257,11 @@ def printLogo():
def main(): def main():
if not Path(GLOBAL.defaultConfigDirectory).is_dir():
os.makedirs(GLOBAL.defaultConfigDirectory)
if Path("config.json").exists(): if Path("config.json").exists():
GLOBAL.configDirectory = Path("config.json") GLOBAL.configDirectory = Path("config.json")
else: else:
if not Path(GLOBAL.defaultConfigDirectory).is_dir():
os.makedirs(GLOBAL.defaultConfigDirectory)
GLOBAL.configDirectory = GLOBAL.defaultConfigDirectory / "config.json" GLOBAL.configDirectory = GLOBAL.defaultConfigDirectory / "config.json"
try: try:
GLOBAL.config = Config(GLOBAL.configDirectory).generate() GLOBAL.config = Config(GLOBAL.configDirectory).generate()