1
0
Fork 0
mirror of synced 2024-06-28 19:10:41 +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

@ -256,13 +256,12 @@ def printLogo():
)
def main():
if not Path(GLOBAL.defaultConfigDirectory).is_dir():
os.makedirs(GLOBAL.defaultConfigDirectory)
if Path("config.json").exists():
GLOBAL.configDirectory = Path("config.json")
else:
if not Path(GLOBAL.defaultConfigDirectory).is_dir():
os.makedirs(GLOBAL.defaultConfigDirectory)
GLOBAL.configDirectory = GLOBAL.defaultConfigDirectory / "config.json"
try:
GLOBAL.config = Config(GLOBAL.configDirectory).generate()
@ -362,4 +361,4 @@ if __name__ == "__main__":
print(GLOBAL.log_stream.getvalue())
if not GLOBAL.arguments.quit: input("\nPress enter to quit\n")