Only encrypt / decrypt fields with a value

This commit is contained in:
shamoon 2024-10-25 23:47:33 -07:00
parent 0a5066ebce
commit e2292ced40
No known key found for this signature in database
2 changed files with 8 additions and 6 deletions

View File

@ -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

View File

@ -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