]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix: correct PAPERLESS_EMPTY_TRASH_DIR to Path (#10227)
authorshamoon <4887959+shamoon@users.noreply.github.com>
Thu, 19 Jun 2025 18:50:23 +0000 (11:50 -0700)
committerGitHub <noreply@github.com>
Thu, 19 Jun 2025 18:50:23 +0000 (11:50 -0700)
src/documents/signals/handlers.py
src/documents/tests/test_file_handling.py
src/paperless/settings.py

index 815a604bba73c372bbc430cf723fa31bc195816e..0c20de95a539c894fde60a5ddb65a1748c6a71dc 100644 (file)
@@ -331,9 +331,8 @@ def cleanup_document_deletion(sender, instance, **kwargs):
             (old_filebase, old_fileext) = os.path.splitext(old_filename)
 
             while True:
-                new_file_path = os.path.join(
-                    settings.EMPTY_TRASH_DIR,
-                    old_filebase + (f"_{counter:02}" if counter else "") + old_fileext,
+                new_file_path = settings.EMPTY_TRASH_DIR / (
+                    old_filebase + (f"_{counter:02}" if counter else "") + old_fileext
                 )
 
                 if os.path.exists(new_file_path):
index a49bd07aa67a8c501f9271e3fb62ae6e167a1352..d5bfa7184de4fd208c2244ff4bfc6a23ce8d7b84 100644 (file)
@@ -188,7 +188,7 @@ class TestFileHandling(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
 
     @override_settings(
         FILENAME_FORMAT="{correspondent}/{correspondent}",
-        EMPTY_TRASH_DIR=tempfile.mkdtemp(),
+        EMPTY_TRASH_DIR=Path(tempfile.mkdtemp()),
     )
     def test_document_delete_trash_dir(self):
         document = Document()
index 41f9f0ce36efebeb2c676fd8ec1e0c79b557f31c..3b69b2fc2a71f44125fd89a4fe8971af0f2589cf 100644 (file)
@@ -270,9 +270,10 @@ DATA_DIR = __get_path("PAPERLESS_DATA_DIR", BASE_DIR.parent / "data")
 NLTK_DIR = __get_path("PAPERLESS_NLTK_DIR", "/usr/share/nltk_data")
 
 # Check deprecated setting first
-EMPTY_TRASH_DIR = os.getenv(
-    "PAPERLESS_TRASH_DIR",
-    os.getenv("PAPERLESS_EMPTY_TRASH_DIR"),
+EMPTY_TRASH_DIR = (
+    __get_path("PAPERLESS_TRASH_DIR", os.getenv("PAPERLESS_EMPTY_TRASH_DIR"))
+    if os.getenv("PAPERLESS_TRASH_DIR") or os.getenv("PAPERLESS_EMPTY_TRASH_DIR")
+    else None
 )
 
 # Lock file for synchronizing changes to the MEDIA directory across multiple