mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
The index is now recreated in case loading fails.
This commit is contained in:
parent
4bf0d834a0
commit
b589b7a5dc
@ -64,15 +64,18 @@ def get_schema():
|
|||||||
|
|
||||||
|
|
||||||
def open_index(recreate=False):
|
def open_index(recreate=False):
|
||||||
if exists_in(settings.INDEX_DIR) and not recreate:
|
# TODO: this is not thread safe. If 2 instances try to create the index
|
||||||
return open_dir(settings.INDEX_DIR)
|
# at the same time, this fails. This currently prevents parallel
|
||||||
else:
|
# tests.
|
||||||
# TODO: this is not thread safe. If 2 instances try to create the index
|
try:
|
||||||
# at the same time, this fails. This currently prevents parallel
|
if exists_in(settings.INDEX_DIR) and not recreate:
|
||||||
# tests.
|
return open_dir(settings.INDEX_DIR)
|
||||||
if not os.path.isdir(settings.INDEX_DIR):
|
except Exception as e:
|
||||||
os.makedirs(settings.INDEX_DIR, exist_ok=True)
|
logger.error(f"Error while opening the index: {e}, recreating.")
|
||||||
return create_in(settings.INDEX_DIR, get_schema())
|
|
||||||
|
if not os.path.isdir(settings.INDEX_DIR):
|
||||||
|
os.makedirs(settings.INDEX_DIR, exist_ok=True)
|
||||||
|
return create_in(settings.INDEX_DIR, get_schema())
|
||||||
|
|
||||||
|
|
||||||
def update_document(writer, doc):
|
def update_document(writer, doc):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user