Ask for password before adding entry instead of after (#951)

* ask for password before adding entry (#799)

This fixes #799 because previously it would allow you to create an
entry using your editor and then attempt to open the journal. This
behaviour is fine for unencrypted journals but with encrypted journals
it means that if you get the password wrong three times then the entry
you just wrote is lost.

Swapping the order around so that the entry is opened first in the code
and then the editor is added means that this can't happen.
This commit is contained in:
Olly Britton 2020-05-16 20:55:04 +01:00 committed by GitHub
parent b4089c125b
commit 7a7818ef24

View file

@ -345,6 +345,13 @@ def run(manual_args=None):
else: else:
_exit_multiline_code = "press Ctrl+D" _exit_multiline_code = "press Ctrl+D"
# This is where we finally open the journal!
try:
journal = open_journal(journal_name, config)
except KeyboardInterrupt:
print("[Interrupted while opening journal]", file=sys.stderr)
sys.exit(1)
if mode_compose and not args.text: if mode_compose and not args.text:
if not sys.stdin.isatty(): if not sys.stdin.isatty():
# Piping data into jrnl # Piping data into jrnl
@ -376,13 +383,6 @@ def run(manual_args=None):
else: else:
sys.exit() sys.exit()
# This is where we finally open the journal!
try:
journal = open_journal(journal_name, config)
except KeyboardInterrupt:
print("[Interrupted while opening journal]", file=sys.stderr)
sys.exit(1)
# Import mode # Import mode
if mode_import: if mode_import:
plugins.get_importer(args.import_).import_(journal, args.input) plugins.get_importer(args.import_).import_(journal, args.input)