export: Remove paranoid assertion.

There are tactical reasons to remove this assertion.

Basically, the reason it's safe to remove is that it's
been around a long time and we would have seen this
operationally. Also, the check to make sure that the
S3 filename thingy matches the avatar hash is a much
stronger check.

We will soon restore a stronger version of this check
that applies to all of our asset types (emojis/avatars/etc.).
This commit is contained in:
Steve Howell 2021-12-06 17:23:32 +00:00 committed by Tim Abbott
parent 59951ae52b
commit b0e5c1d3b9
1 changed files with 0 additions and 5 deletions

View File

@ -1428,13 +1428,11 @@ def export_files_from_s3(
logging.info("Downloading %s files from %s", flavor, bucket_name) logging.info("Downloading %s files from %s", flavor, bucket_name)
avatar_hash_values = set() avatar_hash_values = set()
user_ids = set()
if processing_avatars: if processing_avatars:
for user_profile in UserProfile.objects.filter(realm=realm): for user_profile in UserProfile.objects.filter(realm=realm):
avatar_path = user_avatar_path_from_ids(user_profile.id, realm.id) avatar_path = user_avatar_path_from_ids(user_profile.id, realm.id)
avatar_hash_values.add(avatar_path) avatar_hash_values.add(avatar_path)
avatar_hash_values.add(avatar_path + ".original") avatar_hash_values.add(avatar_path + ".original")
user_ids.add(user_profile.id)
if settings.EMAIL_GATEWAY_BOT is not None: if settings.EMAIL_GATEWAY_BOT is not None:
internal_realm = get_realm(settings.SYSTEM_BOT_REALM) internal_realm = get_realm(settings.SYSTEM_BOT_REALM)
@ -1467,9 +1465,6 @@ def export_files_from_s3(
) )
# Email gateway bot sends messages, potentially including attachments, cross-realm. # Email gateway bot sends messages, potentially including attachments, cross-realm.
print(f"File uploaded by email gateway bot: {key.key} / {key.metadata}") print(f"File uploaded by email gateway bot: {key.key} / {key.metadata}")
elif processing_avatars:
if int(key.metadata["user_profile_id"]) not in user_ids:
raise AssertionError(f"Wrong user_profile_id in key metadata: {key.metadata}")
record = _get_exported_s3_record(bucket_name, key, processing_emoji) record = _get_exported_s3_record(bucket_name, key, processing_emoji)