Skip to content

Commit

Permalink
move the directory creator back to the wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
ajslater committed Feb 5, 2022
1 parent 0d23dac commit df114f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 0 additions & 4 deletions tests/xapian_tests/tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ def setUp(self):
self.ui.build(indexes=[self.index])
self.backend = connections['default'].get_backend()
connections['default']._index = self.ui
try:
Path(self.backend.path).mkdir(parents=True)
except FileExistsError:
pass

def tearDown(self):
self.backend.clear()
Expand Down
5 changes: 5 additions & 0 deletions xapian_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,17 @@ def wrapper(self, *args, **kwargs):
if self.path == MEMORY_DB_NAME:
func(self, *args, **kwargs)
else:
try:
Path(self.path).mkdir(parents=True)
except FileExistsError:
pass
Path(self.filelock.lock_file).touch()
with self.filelock:
func(self, *args, **kwargs)

return wrapper


class InvalidIndexError(HaystackError):
"""Raised when an index can not be opened."""
pass
Expand Down

0 comments on commit df114f4

Please sign in to comment.