@@ -517,7 +517,6 @@ async def _get_markdown_file_handle(self, synapse_client: Synapse) -> "WikiPage"
517517 parent_entity_id = self .owner_id ,
518518 path = file_path ,
519519 )
520-
521520 synapse_client .logger .debug (
522521 f"Uploaded file handle { file_handle .get ('id' )} for wiki page markdown."
523522 )
@@ -585,6 +584,9 @@ async def _determine_wiki_action(
585584 Raises:
586585 ValueError: If required fields are missing.
587586 """
587+ if not self .owner_id :
588+ raise ValueError ("Must provide owner_id to modify a wiki page." )
589+
588590 if self .parent_id :
589591 return "create_sub_wiki_page"
590592
@@ -610,6 +612,8 @@ async def store_async(
610612 ) -> "WikiPage" :
611613 """Store the wiki page. If there is no wiki page, a new wiki page will be created.
612614 If the wiki page already exists, it will be updated.
615+ Subwiki pages are created by passing in a parent_id.
616+ If a parent_id is provided, the wiki page will be created as a subwiki page.
613617
614618 Arguments:
615619 synapse_client: If not passed in and caching was not disabled by
@@ -623,16 +627,14 @@ async def store_async(
623627 ValueError: If owner_id is not provided or if required fields are missing.
624628 """
625629 client = Synapse .get_client (synapse_client = synapse_client )
626- if not self .owner_id :
627- raise ValueError ("Must provide owner_id to modify a wiki page." )
628630
629631 wiki_action = await self ._determine_wiki_action ()
630632 # get the markdown file handle and attachment file handles if the wiki action is valid
631633 if wiki_action :
632- self = await self . _get_markdown_file_handle ( synapse_client = synapse_client )
633- self = await self ._get_attachment_file_handles (
634- synapse_client = synapse_client
635- )
634+ # Update self with the returned WikiPage objects that have file handle IDs set
635+ self = await self ._get_markdown_file_handle ( synapse_client = client )
636+ self = await self . _get_attachment_file_handles ( synapse_client = client )
637+
636638 # Handle root wiki page creation if parent_id is not given
637639 if wiki_action == "create_root_wiki_page" :
638640 client .logger .info (
@@ -663,8 +665,8 @@ async def store_async(
663665 )
664666 # Update existing_wiki with current object's attributes if they are not None
665667 updated_wiki = merge_dataclass_entities (
666- existing_wiki ,
667- self ,
668+ source = self ,
669+ destination = existing_wiki ,
668670 fields_to_ignore = [
669671 "etag" ,
670672 "created_on" ,
@@ -922,7 +924,7 @@ async def get_attachment_async(
922924 else :
923925 # download the file
924926 download_from_url_multi_threaded (
925- presigned_url = presigned_url_info . url , destination = download_location
927+ presigned_url = presigned_url_info , destination = download_location
926928 )
927929 client .logger .debug (
928930 f"Downloaded file { presigned_url_info .file_name } to { download_location } "
0 commit comments