]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Minor improvements for quality of life 905/head
authorTrenton Holmes <holmes.trenton@gmail.com>
Mon, 9 May 2022 19:05:29 +0000 (12:05 -0700)
committerTrenton Holmes <holmes.trenton@gmail.com>
Mon, 9 May 2022 19:05:29 +0000 (12:05 -0700)
docker/docker-prepare.sh
src/documents/management/commands/document_consumer.py

index 47723378472277a4c63b826c000b044d1e45434c..1756d88c4b3adc17eed2abd75cf3fbedd7aa2ade 100755 (executable)
@@ -52,7 +52,7 @@ search_index() {
 
        if [[ (! -f "$index_version_file") || $(<$index_version_file) != "$index_version" ]]; then
                echo "Search index out of date. Updating..."
-               python3 manage.py document_index reindex
+               python3 manage.py document_index reindex --no-progress-bar
                echo $index_version | tee $index_version_file >/dev/null
        fi
 }
index eb6f0a405ba1fad29170833acbc750004a40e4e0..87e3af2c339560b5ce29664a32df6c946d171d8a 100644 (file)
@@ -28,8 +28,11 @@ def _tags_from_path(filepath):
     """Walk up the directory tree from filepath to CONSUMPTION_DIR
     and get or create Tag IDs for every directory.
     """
+    normalized_consumption_dir = os.path.abspath(
+        os.path.normpath(settings.CONSUMPTION_DIR),
+    )
     tag_ids = set()
-    path_parts = Path(filepath).relative_to(settings.CONSUMPTION_DIR).parent.parts
+    path_parts = Path(filepath).relative_to(normalized_consumption_dir).parent.parts
     for part in path_parts:
         tag_ids.add(
             Tag.objects.get_or_create(name__iexact=part, defaults={"name": part})[0].pk,
@@ -39,7 +42,10 @@ def _tags_from_path(filepath):
 
 
 def _is_ignored(filepath: str) -> bool:
-    filepath_relative = PurePath(filepath).relative_to(settings.CONSUMPTION_DIR)
+    normalized_consumption_dir = os.path.abspath(
+        os.path.normpath(settings.CONSUMPTION_DIR),
+    )
+    filepath_relative = PurePath(filepath).relative_to(normalized_consumption_dir)
     return any(filepath_relative.match(p) for p in settings.CONSUMER_IGNORE_PATTERNS)
 
 
@@ -160,6 +166,8 @@ class Command(BaseCommand):
         if not directory:
             raise CommandError("CONSUMPTION_DIR does not appear to be set.")
 
+        directory = os.path.abspath(directory)
+
         if not os.path.isdir(directory):
             raise CommandError(f"Consumption directory {directory} does not exist")