mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-19 20:48:31 +02:00
Avoid data loss by postponing open() (#502)
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.
This commit is contained in:
parent
e78a6523da
commit
3c0d6e54c4
2 changed files with 2 additions and 2 deletions
|
@ -36,8 +36,6 @@ class Journal(object):
|
|||
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)
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue