From ab12294777bae65c3a542ec4c1ddcea9b262067d Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Thu, 17 Oct 2013 16:04:34 -0700 Subject: [PATCH] Only updates config locally on encrypting and decrypting --- jrnl/jrnl.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jrnl/jrnl.py b/jrnl/jrnl.py index d9337308..b82dd54c 100755 --- a/jrnl/jrnl.py +++ b/jrnl/jrnl.py @@ -107,12 +107,15 @@ def touch_journal(filename): util.prompt("[Journal created at {0}]".format(filename)) open(filename, 'a').close() -def update_config(config, new_config, scope): +def update_config(config, new_config, scope, force_local=False): """Updates a config dict with new values - either global if scope is None or config['journals'][scope] is just a string pointing to a journal file, or within the scope""" if scope and type(config['journals'][scope]) is dict: # Update to journal specific config['journals'][scope].update(new_config) + elif scope and force_local: # Convert to dict + config['journals'][scope] = {"journal": config['journals'][scope]} + config['journals'][scope].update(new_config) else: config.update(new_config) @@ -206,14 +209,14 @@ def cli(manual_args=None): encrypt(journal, filename=args.encrypt) # Not encrypting to a separate file: update config! if not args.encrypt: - update_config(original_config, {"encrypt": True}, journal_name) + update_config(original_config, {"encrypt": True}, journal_name, force_local=True) install.save_config(original_config, config_path=CONFIG_PATH) elif args.decrypt is not False: decrypt(journal, filename=args.decrypt) # Not decrypting to a separate file: update config! if not args.decrypt: - update_config(original_config, {"encrypt": False}, journal_name) + update_config(original_config, {"encrypt": False}, journal_name, force_local=True) install.save_config(original_config, config_path=CONFIG_PATH) elif args.delete_last: