mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Upgrade prompt for encrypted jrnls
This commit is contained in:
parent
72ab49d382
commit
9c4294ca68
1 changed files with 28 additions and 7 deletions
|
@ -6,6 +6,7 @@ import util
|
||||||
from . import __version__
|
from . import __version__
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def upgrade_encrypted_journal(filename, key_plain):
|
def upgrade_encrypted_journal(filename, key_plain):
|
||||||
"""Decrypts a journal in memory using the jrnl 1.x encryption scheme
|
"""Decrypts a journal in memory using the jrnl 1.x encryption scheme
|
||||||
and returns it in plain text."""
|
and returns it in plain text."""
|
||||||
|
@ -31,14 +32,34 @@ def upgrade_jrnl_if_necessary(config_path):
|
||||||
if not config.strip().startswith("{"):
|
if not config.strip().startswith("{"):
|
||||||
return
|
return
|
||||||
|
|
||||||
util.prompt("Welcome to jrnl {}".format(__version__))
|
config = util.load_config(config_path)
|
||||||
util.prompt("jrnl will now upgrade your configuration and journal files.")
|
|
||||||
util.prompt("Please note that jrnl 1.x is NOT forward compatible with this version of jrnl.")
|
util.prompt("""Welcome to jrnl {}
|
||||||
util.prompt("If you choose to proceed, you will not be able to use your journals with")
|
jrnl will now upgrade your configuration and journal files.
|
||||||
util.prompt("older versions of jrnl anymore.")
|
Please note that jrnl 1.x is NOT forward compatible with this version of jrnl.
|
||||||
|
If you choose to proceed, you will not be able to use your journals with
|
||||||
|
older versions of jrnl anymore.""".format(__version__))
|
||||||
|
|
||||||
|
encrypted_journals = {}
|
||||||
|
plain_journals = {}
|
||||||
|
for journal, journal_conf in config['journals'].items():
|
||||||
|
if isinstance(journal_conf, dict):
|
||||||
|
if journal_conf.get("encrypted"):
|
||||||
|
encrypted_journals[journal] = journal_conf.get("journal")
|
||||||
|
else:
|
||||||
|
plain_journals[journal] = journal_conf.get("journal")
|
||||||
|
else:
|
||||||
|
plain_journals[journal] = journal_conf.get("journal")
|
||||||
|
if encrypted_journals:
|
||||||
|
util.prompt("Following encrypted journals will be upgraded to jrnl {}:".format(__version__))
|
||||||
|
for journal, path in encrypted_journals.items():
|
||||||
|
util.prompt(" {:20} -> {}".format(journal, path))
|
||||||
|
if plain_journals:
|
||||||
|
util.prompt("Following plain text journals will be not be touched:")
|
||||||
|
for journal, path in plain_journals.items():
|
||||||
|
util.prompt(" {:20} -> {}".format(journal, path))
|
||||||
|
|
||||||
cont = util.yesno("Continue upgrading jrnl?", default=False)
|
cont = util.yesno("Continue upgrading jrnl?", default=False)
|
||||||
if not cont:
|
if not cont:
|
||||||
util.prompt("jrnl NOT upgraded, exiting.")
|
util.prompt("jrnl NOT upgraded, exiting.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
util.prompt("")
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue