Skip to content

Commit

Permalink
Avoid data loss by postponing open() (jrnl-org#502) (jrnl-org#545)
Browse files Browse the repository at this point in the history
Postpone the reading of existing entries until a new entry
has been obtained and is ready to be appended to the journal.

This patch reduces the likelihood of losing entries when the
user has launched concurrent jrnl sessions to add multiple
entries. A proper solution would require locking the journal
file for the time between reading and writing, but this is
already good enough for typical interactive use cases.
  • Loading branch information
semi authored and maebert committed Jun 26, 2018
1 parent e78a652 commit a2462ed
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 0 additions & 2 deletions jrnl/Journal.py
Expand Up @@ -36,8 +36,6 @@ def __init__(self, name='default', **kwargs):
self.search_tags = None # Store tags we're highlighting
self.name = name

self.open()

def __len__(self):
"""Returns the number of entries"""
return len(self.entries)
Expand Down
2 changes: 2 additions & 0 deletions jrnl/cli.py
Expand Up @@ -216,6 +216,8 @@ def run(manual_args=None):
else:
mode_compose = False

journal.open()

# Writing mode
if mode_compose:
raw = " ".join(args.text).strip()
Expand Down

0 comments on commit a2462ed

Please sign in to comment.