[GH-632] confirming that each journal can be parsed during upgrade, and aborting upgrade if not

[GH-632] raising exception in upgrade.py on fail
Handling it in install.py to prevent config from being overwritten when upgrade fails
[GH-632] removing unnecessary whitespace
[GH-632] removing unreachable return statement
[GH-632] adding call to action to report issue when upgrade fails
This commit is contained in:
Micah Jerome Ellison 2019-08-24 13:50:10 -07:00
parent 328faa401c
commit 8abbdf4db5
6 changed files with 68 additions and 30 deletions

View file

@ -14,6 +14,7 @@ from .Journal import PlainJournal
from .EncryptedJournal import EncryptedJournal
import yaml
import logging
import sys
DEFAULT_CONFIG_NAME = 'jrnl.yaml'
DEFAULT_JOURNAL_NAME = 'journal.txt'
@ -85,8 +86,18 @@ def load_or_install_jrnl():
if os.path.exists(config_path):
log.debug('Reading configuration from file %s', config_path)
config = util.load_config(config_path)
upgrade.upgrade_jrnl_if_necessary(config_path)
try:
upgrade.upgrade_jrnl_if_necessary(config_path)
except upgrade.UpgradeValidationException:
util.prompt("Aborting upgrade.")
util.prompt("Please tell us about this problem at the following URL:")
util.prompt("https://github.com/jrnl-org/jrnl/issues/new?title=UpgradeValidationException")
util.prompt("Exiting.")
sys.exit(1)
upgrade_config(config)
return config
else:
log.debug('Configuration file not found, installing jrnl...')