mirror of https://github.com/zulip/zulip.git
export: Add check_metadata flag.
This commit is contained in:
parent
0166f13d83
commit
42ecabe967
|
@ -1455,25 +1455,31 @@ def export_files_from_s3(
|
|||
|
||||
key = bucket.Object(bkey.key)
|
||||
|
||||
if "realm_id" not in key.metadata:
|
||||
raise AssertionError(f"Missing realm_id in key metadata: {key.metadata}")
|
||||
"""
|
||||
For very old realms we may not have proper metadata. If you really need
|
||||
an export to bypass these checks, flip the following flag.
|
||||
"""
|
||||
checking_metadata = True
|
||||
if checking_metadata:
|
||||
if "realm_id" not in key.metadata:
|
||||
raise AssertionError(f"Missing realm_id in key metadata: {key.metadata}")
|
||||
|
||||
if "user_profile_id" not in key.metadata:
|
||||
raise AssertionError(f"Missing user_profile_id in key metadata: {key.metadata}")
|
||||
if "user_profile_id" not in key.metadata:
|
||||
raise AssertionError(f"Missing user_profile_id in key metadata: {key.metadata}")
|
||||
|
||||
if int(key.metadata["user_profile_id"]) not in user_ids:
|
||||
continue
|
||||
if int(key.metadata["user_profile_id"]) not in user_ids:
|
||||
continue
|
||||
|
||||
# This can happen if an email address has moved realms
|
||||
if key.metadata["realm_id"] != str(realm.id):
|
||||
if email_gateway_bot is None or key.metadata["user_profile_id"] != str(
|
||||
email_gateway_bot.id
|
||||
):
|
||||
raise AssertionError(
|
||||
f"Key metadata problem: {key.key} / {key.metadata} / {realm.id}"
|
||||
)
|
||||
# Email gateway bot sends messages, potentially including attachments, cross-realm.
|
||||
print(f"File uploaded by email gateway bot: {key.key} / {key.metadata}")
|
||||
# This can happen if an email address has moved realms
|
||||
if key.metadata["realm_id"] != str(realm.id):
|
||||
if email_gateway_bot is None or key.metadata["user_profile_id"] != str(
|
||||
email_gateway_bot.id
|
||||
):
|
||||
raise AssertionError(
|
||||
f"Key metadata problem: {key.key} / {key.metadata} / {realm.id}"
|
||||
)
|
||||
# Email gateway bot sends messages, potentially including attachments, cross-realm.
|
||||
print(f"File uploaded by email gateway bot: {key.key} / {key.metadata}")
|
||||
|
||||
record = _get_exported_s3_record(bucket_name, key, processing_emoji)
|
||||
|
||||
|
|
Loading…
Reference in New Issue