A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Ensure, that document root is not deleted
Wolf-Bastian Poettner845313db5226
diff --git a/src/documents/models.py b/src/documents/models.pyindex 39dcc4a37..17357c1a7 100644--- a/src/documents/models.py+++ b/src/documents/models.py@@ -415,7 +415,10 @@ class Document(models.Model):def try_delete_empty_directories(directory):# Go up in the directory hierarchy and try to delete all directories- while directory != Document.filename_to_path(""):+ directory = os.path.normpath(directory)+ root = os.path.normpath(Document.filename_to_path(""))++ while directory != root:# Try to delete the current directorytry:os.rmdir(directory)@@ -425,6 +428,7 @@ def try_delete_empty_directories(directory):# Cut off actual directory and go one level updirectory, _ = os.path.split(directory)+ directory = os.path.normpath(directory)@receiver(models.signals.m2m_changed, sender=Document.tags.through)diff --git a/src/documents/tests/test_file_handling.py b/src/documents/tests/test_file_handling.pyindex f6c8d0eba..fae1c0634 100644--- a/src/documents/tests/test_file_handling.py+++ b/src/documents/tests/test_file_handling.py@@ -319,7 +319,7 @@ class TestDate(TestCase):self.assertEqual(os.path.isdir(settings.MEDIA_ROOT +"/documents/originals/none"), False)self.assertEqual(os.path.isdir(settings.MEDIA_ROOT +- "/documents/originals"), False)+ "/documents/originals"), True)@override_settings(MEDIA_ROOT="/tmp/paperless-tests-{}".format(str(uuid4())[:8]))