]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Only delete the ContentTypes and Permissions once, not the loop (#4623)
authorTrenton H <797416+stumpylog@users.noreply.github.com>
Fri, 17 Nov 2023 20:24:49 +0000 (12:24 -0800)
committerGitHub <noreply@github.com>
Fri, 17 Nov 2023 20:24:49 +0000 (12:24 -0800)
src/documents/management/commands/document_importer.py

index 7a3e40f28cfd35b2e01763b17083ef219f2d2c04..9895104c3c4ace5525159e28d49f542b8a01a200 100644 (file)
@@ -118,10 +118,10 @@ class Command(BaseCommand):
             # Fill up the database with whatever is in the manifest
             try:
                 with transaction.atomic():
+                    # delete these since pk can change, re-created from import
+                    ContentType.objects.all().delete()
+                    Permission.objects.all().delete()
                     for manifest_path in manifest_paths:
-                        # delete these since pk can change, re-created from import
-                        ContentType.objects.all().delete()
-                        Permission.objects.all().delete()
                         call_command("loaddata", manifest_path)
             except (FieldDoesNotExist, DeserializationError, IntegrityError) as e:
                 self.stdout.write(self.style.ERROR("Database import failed"))