From 55097ab61f415fddb476700ddcf7a6a03f0cb9e2 Mon Sep 17 00:00:00 2001 From: Micah Jerome Ellison Date: Sat, 21 Aug 2021 13:19:49 -0700 Subject: [PATCH] Warn when encrypt is true and journal type is directory/DayOne --- jrnl/Journal.py | 6 ++++++ tests/bdd/features/encrypt.feature | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/jrnl/Journal.py b/jrnl/Journal.py index 6d3c6886..e8f24ac9 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -405,6 +405,12 @@ def open_journal(journal_name, config, legacy=False): config["journal"] = os.path.expanduser(os.path.expandvars(config["journal"])) if os.path.isdir(config["journal"]): + if config["encrypt"]: + print( + "Warning: This journal's config has 'encrypt' set to true, but this type of journal can't be encrypted.", + file=sys.stderr, + ) + if config["journal"].strip("/").endswith(".dayone") or "entries" in os.listdir( config["journal"] ): diff --git a/tests/bdd/features/encrypt.feature b/tests/bdd/features/encrypt.feature index daca722f..af141172 100644 --- a/tests/bdd/features/encrypt.feature +++ b/tests/bdd/features/encrypt.feature @@ -41,10 +41,11 @@ Feature: Encrypting and decrypting journals Then we should be prompted for a password And the output should contain "2013-06-10 15:40 Life is good" + Scenario Outline: Running jrnl with encrypt: true on unencryptable journals Given we use the config "" - When we run "jrnl here is a new entry" - Then the error output should contain "is not encrypted" + When we run "jrnl --config-override encrypt true here is a new entry" + Then the error output should contain "this type of journal can't be encrypted" Examples: configs | config_file |