Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

make the index dir if it does not exist.

Jonas Winkler2c9555015b7b
diff --git a/src/documents/index.py b/src/documents/index.py
index d46ccedaf..ad3a50010 100644
--- a/src/documents/index.py
+++ b/src/documents/index.py
@@ -1,6 +1,8 @@
import logging
+import os
from contextlib import contextmanager
+from django.conf import settings
from whoosh import highlight
from whoosh.fields import Schema, TEXT, NUMERIC
from whoosh.highlight import Formatter, get_text
@@ -8,7 +10,6 @@ from whoosh.index import create_in, exists_in, open_dir
from whoosh.qparser import MultifieldParser
from whoosh.writing import AsyncWriter
-from paperless import settings
logger = logging.getLogger(__name__)
@@ -69,6 +70,8 @@ def open_index(recreate=False):
# TODO: this is not thread safe. If 2 instances try to create the index
# at the same time, this fails. This currently prevents parallel
# tests.
+ if not os.path.isdir(settings.INDEX_DIR):
+ os.makedirs(settings.INDEX_DIR, exist_ok=True)
return create_in(settings.INDEX_DIR, get_schema())