mirror of
https://github.com/Hopiu/xapian-haystack.git
synced 2026-03-16 22:20:31 +00:00
Fixing untrustable os.path.exists
As per https://stackoverflow.com/a/3112717/1067833, os.path.exists sometimes delivers a wrong value. These are corner cases, but mine is exactly one: I run xapian-haystack in a multiprocess environment (indexing and django server), on an LXC container, which has its mount probably mounted from an NFS server (I have no control/information over it). This corner case results the os.path.exists give `True` for one process and `False` for another, resulting in the exception I handle with this patch.
This commit is contained in:
parent
253c4c2898
commit
3c322a9552
1 changed files with 5 additions and 2 deletions
|
|
@ -193,8 +193,11 @@ class XapianSearchBackend(BaseSearchBackend):
|
|||
|
||||
self.path = connection_options.get('PATH')
|
||||
|
||||
if self.path != MEMORY_DB_NAME and not os.path.exists(self.path):
|
||||
os.makedirs(self.path)
|
||||
if self.path != MEMORY_DB_NAME:
|
||||
try:
|
||||
os.makedirs(self.path)
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
||||
self.flags = connection_options.get('FLAGS', DEFAULT_XAPIAN_FLAGS)
|
||||
self.language = getattr(settings, 'HAYSTACK_XAPIAN_LANGUAGE', 'english')
|
||||
|
|
|
|||
Loading…
Reference in a new issue