コード例 #1
0
def restore_data_from_archive(archive_transaction: ArchiveTransaction) -> None:
    restore_messages_from_archive(archive_transaction.id)
    restore_models_with_message_key_from_archive(archive_transaction.id)
    restore_attachments_from_archive(archive_transaction.id)
    restore_attachment_messages_from_archive(archive_transaction.id)

    archive_transaction.restored = True
    archive_transaction.save()
コード例 #2
0
ファイル: retention.py プロジェクト: stjordanis/zulip
def restore_data_from_archive(archive_transaction: ArchiveTransaction) -> int:
    logger.info("Restoring %s", archive_transaction)
    # transaction.atomic needs to be used here, rather than being a wrapper on the whole function,
    # so that when we log "Finished", the process has indeed finished - and that happens only after
    # leaving the atomic block - Django does work committing the changes to the database when
    # the block ends.
    with transaction.atomic():
        msg_ids = restore_messages_from_archive(archive_transaction.id)
        restore_models_with_message_key_from_archive(archive_transaction.id)
        restore_attachments_from_archive(archive_transaction.id)
        restore_attachment_messages_from_archive(archive_transaction.id)

        archive_transaction.restored = True
        archive_transaction.save()

    logger.info("Finished. Restored %s messages", len(msg_ids))
    return len(msg_ids)