Skip to content

Commit 94ff7de

Browse files
committed
Workaround bibtex race condition due to delayed persistance
Calling `bib_cache.get()` directly after `bib_cache.set()` may raise FileNotFoundError as cache is stored on disk via background threads and `.get()` trying to validate cache file's modification time stamp. This commit therefore teaches `.set()` to directly return cache values from RAM, which are about to being saved to disk. Validating modification time would be redundant anyway. Note: The whole plugin and caching infrastructure is a hopeless mess!
1 parent 6fdd6c3 commit 94ff7de

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

latextools/utils/bibcache.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ def _write_bib_cache():
6464
self._dirty = True
6565
self._schedule_save()
6666

67+
return formatted_entries[1]
68+
6769
def cache(self, func):
6870
try:
6971
return self.get()

plugins/bibliography/new_bibliography.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ def get_entries(self, *bib_files):
148148
logger.info("Loaded %d bibitems", len(bib_entries))
149149

150150
try:
151-
bib_cache.set(bib_entries)
152-
fmt_entries = bib_cache.get()
151+
fmt_entries = bib_cache.set(bib_entries)
153152
entries.extend(fmt_entries)
154153
except Exception:
155154
traceback.print_exc()

plugins/bibliography/traditional_bibliography.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ def get_entries(self, *bib_files):
103103
logger.info("Loaded %d bibitems", len(bib_entries))
104104

105105
try:
106-
bib_cache.set(bib_entries)
107-
fmt_entries = bib_cache.get()
106+
fmt_entries = bib_cache.set(bib_entries)
108107
entries.extend(fmt_entries)
109108
except Exception:
110109
traceback.print_exc()

0 commit comments

Comments
 (0)