jrnl icon indicating copy to clipboard operation
jrnl copied to clipboard

Creating new entries with multiple simultaneous jrnl processes overwrites journal

Open wtraylor opened this issue 4 years ago • 1 comments

Bug Report

Environment

jrnl: v2.5
Python: 3.9.0 (default, Oct  7 2020, 23:09:01)
[GCC 10.2.0]
OS: Linux 5.9.12-arch1-1

Installed through Archlinux package community/jrnl.

Current Behavior

When creating two simultaneous editor windows by calling jrnl and closing them one after the other, only the entry from the window that was closed last will be added to the journal file. The other entry is lost.

Expected Behavior

Both entries are added to the journal file.

Repro Steps

Config file:

editor: vim
journals:
  default: /home/living/jrnl.txt
  1. Call jrnl. The editor (Vim) opens. Type "closed last", but don’t close the editor.
  2. Call jrnl again in another terminal window. A second instance of Vim opens. Type "closed first".
  3. Close the second editor session. Jrnl prints [Entry added to default journal]
  4. Close the first editor session. Jrnl prints [Journal 'default' created at /home/living/jrnl.txt] [Entry added to default journal]

Now, jrnl.txt only contains the entry “closed last”. The other entry is lost.

This happens also with existing journal files, not only with a newly created one as described above.

wtraylor avatar Dec 11 '20 15:12 wtraylor

Thank you for filing this!

It looks like this was a regression caused by #799 .

The fix for this issue without regressing #799 is to move the password prompt back. We should prompt for a password (for encrypted journals) after writing a new entry. If the user fails their password 3 times, though, we should send them back to the editor with their content intact instead of dying and losing the new entry.

This way, we can fix both issues without more regressions.

wren avatar Dec 12 '20 19:12 wren