Skip to content

Commit

Permalink
Merge pull request #906 from kobotoolbox/fix-missing-encrypted-files
Browse files Browse the repository at this point in the history
Fix missing encrypted files when exporting or viewing submitted data
  • Loading branch information
jnm authored Nov 16, 2023
2 parents 72442cb + 8034d86 commit a7e6380
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def handle(self, *args, **kwargs):

queryset = Attachment.all_objects.filter(
Q(media_file_basename='audit.csv')
| Q(media_file_basename__endswith='.enc')
| Q(media_file_basename__regex=r'^\d{10,}\.(m4a|amr)$'),
deleted_at__isnull=False,
)
Expand All @@ -58,6 +59,7 @@ def handle(self, *args, **kwargs):

att_queryset = Attachment.all_objects.filter(
Q(media_file_basename='audit.csv')
| Q(media_file_basename__endswith='.enc')
| Q(media_file_basename__regex=r'^\d{10,}\.(m4a|amr)$')
)
if not force:
Expand All @@ -82,6 +84,7 @@ def handle(self, *args, **kwargs):
)
Attachment.all_objects.filter(
Q(media_file_basename='audit.csv')
| Q(media_file_basename__endswith='.enc')
| Q(media_file_basename__regex=r'^\d+\.(m4a|amr)$'),
instance_id=instance.pk,
).update(deleted_at=None)
Expand Down
1 change: 1 addition & 0 deletions onadata/libs/utils/logger_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ def get_soft_deleted_attachments(instance: Instance) -> list[Attachment]:
# Bug comes from `get_xform_media_question_xpaths()`
queryset = Attachment.objects.filter(instance=instance).exclude(
Q(media_file_basename__in=basenames)
| Q(media_file_basename__endswith='.enc')
| Q(media_file_basename='audit.csv')
| Q(media_file_basename__regex=r'^\d{10,}\.(m4a|amr)$')
)
Expand Down

0 comments on commit a7e6380

Please sign in to comment.