Warn when encrypt is true and journal type is directory/DayOne

This commit is contained in:
Micah Jerome Ellison 2021-08-21 13:19:49 -07:00
parent 6561b50311
commit 55097ab61f
2 changed files with 9 additions and 2 deletions

View file

@ -405,6 +405,12 @@ def open_journal(journal_name, config, legacy=False):
config["journal"] = os.path.expanduser(os.path.expandvars(config["journal"])) config["journal"] = os.path.expanduser(os.path.expandvars(config["journal"]))
if os.path.isdir(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( if config["journal"].strip("/").endswith(".dayone") or "entries" in os.listdir(
config["journal"] config["journal"]
): ):

View file

@ -41,10 +41,11 @@ Feature: Encrypting and decrypting journals
Then we should be prompted for a password Then we should be prompted for a password
And the output should contain "2013-06-10 15:40 Life is good" And the output should contain "2013-06-10 15:40 Life is good"
Scenario Outline: Running jrnl with encrypt: true on unencryptable journals Scenario Outline: Running jrnl with encrypt: true on unencryptable journals
Given we use the config "<config_file>" Given we use the config "<config_file>"
When we run "jrnl here is a new entry" When we run "jrnl --config-override encrypt true here is a new entry"
Then the error output should contain "is not encrypted" Then the error output should contain "this type of journal can't be encrypted"
Examples: configs Examples: configs
| config_file | | config_file |