diff --git a/src/documents/signals/handlers.py b/src/documents/signals/handlers.py index 815a604bb..0c20de95a 100644 --- a/src/documents/signals/handlers.py +++ b/src/documents/signals/handlers.py @@ -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): diff --git a/src/documents/tests/test_file_handling.py b/src/documents/tests/test_file_handling.py index a49bd07aa..d5bfa7184 100644 --- a/src/documents/tests/test_file_handling.py +++ b/src/documents/tests/test_file_handling.py @@ -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() diff --git a/src/paperless/settings.py b/src/paperless/settings.py index 41f9f0ce3..3b69b2fc2 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -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