]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fixes minor depracation I noticed
authorTrenton Holmes <797416+stumpylog@users.noreply.github.com>
Mon, 26 Dec 2022 21:43:30 +0000 (13:43 -0800)
committerTrenton H <797416+stumpylog@users.noreply.github.com>
Wed, 11 Jan 2023 15:52:58 +0000 (07:52 -0800)
src/documents/signals/handlers.py
src/documents/views.py

index 4c2554f02ec395912439634bd989aa23013b9377..cd42c90303ed99e8ddf7daec8cf7422d2962b5e7 100644 (file)
@@ -447,7 +447,7 @@ def update_filename_and_move_files(sender, instance, **kwargs):
             )
 
         except (OSError, DatabaseError, CannotMoveFilesException) as e:
-            logger.warn(f"Exception during file handling: {e}")
+            logger.warning(f"Exception during file handling: {e}")
             # This happens when either:
             #  - moving the files failed due to file system errors
             #  - saving to the database failed due to database errors
index 147dd2e078551b5fd339a7dde65c24553de38759..abd2e5f2fa6180fe80e530a96e3b2f417d5d42bb 100644 (file)
@@ -12,6 +12,7 @@ from time import mktime
 from unicodedata import normalize
 from urllib.parse import quote
 
+import pathvalidate
 from django.conf import settings
 from django.contrib.auth.models import User
 from django.db.models import Case
@@ -625,7 +626,7 @@ class PostDocumentView(GenericAPIView):
         os.makedirs(settings.SCRATCH_DIR, exist_ok=True)
 
         temp_file_path = Path(tempfile.mkdtemp(dir=settings.SCRATCH_DIR)) / Path(
-            doc_name,
+            pathvalidate.sanitize_filename(doc_name),
         )
 
         temp_file_path.write_bytes(doc_data)
@@ -634,8 +635,9 @@ class PostDocumentView(GenericAPIView):
 
         task_id = str(uuid.uuid4())
 
-        async_task = consume_file.delay(
-            temp_file_path,
+        consume_file.delay(
+            # Paths are not JSON friendly
+            str(temp_file_path),
             override_title=title,
             override_correspondent_id=correspondent_id,
             override_document_type_id=document_type_id,