jrnl icon indicating copy to clipboard operation
jrnl copied to clipboard

jrnl should not create 0-length "encrypted" file on startup

Open dcg929 opened this issue 3 years ago • 2 comments

Support Request

Environment

  • Jrnl --diagnostic output: <!-- Run jrnl --diagnostic and paste the output -->
  • Install method: brew

What are you trying to do?

installed jrnl and created jrnl in Documents folder with encryption.

Set password Closed jrnl and tried to reopen Inputting password that was just set produces Password is incorrect

What have you tried?

Other Information

dcg929 avatar Jun 02 '22 18:06 dcg929

Hi @dcg929, thanks for reporting. It looks like jrnl creates an empty file on startup, and empty files can't be decrypted since there is nothing to decrypt.

Instead of creating this empty file during installation, it should still save the encrypted file. And in fact, jrnl does this properly in edit mode -- for instance, one can run jrnl --edit on an encrypted journal, delete the entire journal, and save it. The file should be around 100 bytes and it will still decrypt just fine on future jrnl invocations.

A resolution to this bug should have:

  • [x] A fix that saves a new empty encrypted jrnl properly when first setting up jrnl
  • [x] A BDD test for this fix

This is probably best resolved by encrypting an empty string and saving the file with it, rather than simply touching the file on install.

micahellison avatar Jun 04 '22 19:06 micahellison

Oh, forgot to mention the workaround! If you delete your original empty journal file (which you can find by running jrnl --list), you should be able to get past this issue.

micahellison avatar Jun 04 '22 19:06 micahellison