Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jrnl upgrade does not fail gracefully when a journal file is missing from the configuration #690

Closed
alichtman opened this issue Oct 25, 2019 · 1 comment
Labels
bug Something isn't working 📌 This can't go stale
Milestone

Comments

@alichtman
Copy link
Contributor

This is an edge case, but should still be handled gracefully.

$ jrnl
Welcome to jrnl v2.0.1.

It looks like you've been using an older version of jrnl until now. That's
okay - jrnl will now upgrade your configuration and journal files. Afterwards
you can enjoy all of the great new features that come with jrnl 2:

- Support for storing your journal in multiple files
- Faster reading and writing for large journals
- New encryption back-end that makes installing jrnl much easier
- Tons of bug fixes

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.

Following plain text journals will upgraded to jrnl v2.0.1:
    default -> /Users/alichtman/journals/journal.txt
    tech    -> /Users/alichtman/journals/tech.txt
Continue upgrading jrnl? [y/N]
y

Upgrading plain text 'default' journal stored in /Users/alichtman/journals/journal.txt...
  Created a backup at /Users/alichtman/journals/journal.txt.backup

Upgrading plain text 'tech' journal stored in /Users/alichtman/journals/tech.txt...
  Created a backup at /Users/alichtman/journals/tech.txt.backup
Traceback (most recent call last):
  File "/usr/local/bin/jrnl", line 10, in <module>
    sys.exit(run())
    │        └ <function run at 0x107fba5f0><module 'sys' (built-in)>
  File "/usr/local/lib/python3.7/site-packages/jrnl/cli.py", line 148, in run
    config = install.load_or_install_jrnl()
             └ <module 'jrnl.install' from '/usr/local/lib/python3.7/site-packages/jrnl/install.py'>
  File "/usr/local/lib/python3.7/site-packages/jrnl/install.py", line 92, in load_or_install_jrnl
    upgrade.upgrade_jrnl_if_necessary(config_path)
    │                                 └ '/Users/alichtman/.jrnl_config'<module 'jrnl.upgrade' from '/usr/local/lib/python3.7/site-packages/jrnl/upgrade.py'>
  File "/usr/local/lib/python3.7/site-packages/jrnl/upgrade.py", line 95, in upgrade_jrnl_if_necessary
    backup(path)
    │      └ '/Users/alichtman/journals/tech.txt'<function backup at 0x107d7bc20>
  File "/usr/local/lib/python3.7/site-packages/jrnl/upgrade.py", line 15, in backup
    with open(filename, 'rb' if binary else 'r') as original:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/alichtman/journals/tech.txt'

The file /Users/alichtman/journals/tech.txt does not exist, but is included in my config.

$ cat ~/.jrnl_config
{
  "journals": {
    "default": "/Users/alichtman/journals/journal.txt",
    "tech": "/Users/alichtman/journals/tech.txt"
  },
  ...
}

I'd suggest prompting the user to either fix the config or create the file.

@micahellison micahellison changed the title jrnl Upgrade Exception on Missing Journal File jrnl upgrade does not fail gracefully when a journal file is missing from the configuration Nov 2, 2019
@micahellison micahellison added the bug Something isn't working label Nov 2, 2019
@stale
Copy link

stale bot commented Jan 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Inactive issue: will be closed soon if no activity label Jan 1, 2020
@wren wren added the 📌 This can't go stale label Jan 2, 2020
@stale stale bot removed the stale Inactive issue: will be closed soon if no activity label Jan 2, 2020
@wren wren closed this as completed May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 📌 This can't go stale
Projects
None yet
Development

No branches or pull requests

3 participants