From e2292ced400f0d5876f55e53f1bd2a71a66c8808 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Fri, 25 Oct 2024 23:47:33 -0700 Subject: [PATCH] Only encrypt / decrypt fields with a value --- src/documents/management/commands/document_exporter.py | 7 ++++--- src/documents/management/commands/document_importer.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/documents/management/commands/document_exporter.py b/src/documents/management/commands/document_exporter.py index 081c2c12b..6a23a701a 100644 --- a/src/documents/management/commands/document_exporter.py +++ b/src/documents/management/commands/document_exporter.py @@ -565,9 +565,10 @@ class Command(CryptMixin, BaseCommand): crypt_fields = crypt_config["fields"] for manifest_record in manifest[exporter_key]: for field in crypt_fields: - manifest_record["fields"][field] = self.encrypt_string( - value=manifest_record["fields"][field], - ) + if manifest_record["fields"][field]: + manifest_record["fields"][field] = self.encrypt_string( + value=manifest_record["fields"][field], + ) elif ( MailAccount.objects.count() > 0 diff --git a/src/documents/management/commands/document_importer.py b/src/documents/management/commands/document_importer.py index a402466f4..08812e9d0 100644 --- a/src/documents/management/commands/document_importer.py +++ b/src/documents/management/commands/document_importer.py @@ -414,9 +414,10 @@ class Command(CryptMixin, BaseCommand): ): had_at_least_one_record = True for field in crypt_fields: - record["fields"][field] = self.decrypt_string( - value=record["fields"][field], - ) + if record["fields"][field]: + record["fields"][field] = self.decrypt_string( + value=record["fields"][field], + ) if had_at_least_one_record: # It's annoying, but the DB is loaded from the JSON directly