@@ -517,7 +517,6 @@ async def _get_markdown_file_handle(self, synapse_client: Synapse) -> "WikiPage"
517
517
parent_entity_id = self .owner_id ,
518
518
path = file_path ,
519
519
)
520
-
521
520
synapse_client .logger .debug (
522
521
f"Uploaded file handle { file_handle .get ('id' )} for wiki page markdown."
523
522
)
@@ -585,6 +584,9 @@ async def _determine_wiki_action(
585
584
Raises:
586
585
ValueError: If required fields are missing.
587
586
"""
587
+ if not self .owner_id :
588
+ raise ValueError ("Must provide owner_id to modify a wiki page." )
589
+
588
590
if self .parent_id :
589
591
return "create_sub_wiki_page"
590
592
@@ -610,6 +612,8 @@ async def store_async(
610
612
) -> "WikiPage" :
611
613
"""Store the wiki page. If there is no wiki page, a new wiki page will be created.
612
614
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.
613
617
614
618
Arguments:
615
619
synapse_client: If not passed in and caching was not disabled by
@@ -623,16 +627,14 @@ async def store_async(
623
627
ValueError: If owner_id is not provided or if required fields are missing.
624
628
"""
625
629
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." )
628
630
629
631
wiki_action = await self ._determine_wiki_action ()
630
632
# get the markdown file handle and attachment file handles if the wiki action is valid
631
633
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
+
636
638
# Handle root wiki page creation if parent_id is not given
637
639
if wiki_action == "create_root_wiki_page" :
638
640
client .logger .info (
@@ -663,8 +665,8 @@ async def store_async(
663
665
)
664
666
# Update existing_wiki with current object's attributes if they are not None
665
667
updated_wiki = merge_dataclass_entities (
666
- existing_wiki ,
667
- self ,
668
+ source = self ,
669
+ destination = existing_wiki ,
668
670
fields_to_ignore = [
669
671
"etag" ,
670
672
"created_on" ,
@@ -922,7 +924,7 @@ async def get_attachment_async(
922
924
else :
923
925
# download the file
924
926
download_from_url_multi_threaded (
925
- presigned_url = presigned_url_info . url , destination = download_location
927
+ presigned_url = presigned_url_info , destination = download_location
926
928
)
927
929
client .logger .debug (
928
930
f"Downloaded file { presigned_url_info .file_name } to { download_location } "
0 commit comments