@@ -526,44 +526,47 @@ async def store_async(
526526 file_path = self ._to_gzip_file (
527527 wiki_content = self .markdown , synapse_client = client
528528 )
529- # Upload the gzipped file to get a file handle
530- file_handle = await upload_file_handle (
531- syn = client ,
532- parent_entity_id = self .owner_id ,
533- path = file_path ,
534- )
535-
536- client .logger .info (
537- f"Uploaded file handle { file_handle .get ('id' )} for wiki page markdown."
538- )
539- # delete the temp gzip file
540- os .remove (file_path )
541- client .logger .debug (f"Deleted temp gzip file { file_path } " )
542-
543- # Set the markdown file handle ID from the upload response
544- self .markdown_file_handle_id = file_handle .get ("id" )
545-
546- # Convert attachments to gzipped file if needed
547- if self .attachments :
548- file_handles = []
549- for attachment in self .attachments :
550- file_path = self ._to_gzip_file (
551- wiki_content = attachment , synapse_client = client
552- )
529+ try :
530+ # Upload the gzipped file to get a file handle
553531 file_handle = await upload_file_handle (
554532 syn = client ,
555533 parent_entity_id = self .owner_id ,
556534 path = file_path ,
557535 )
558- file_handles . append ( file_handle . get ( "id" ))
536+
559537 client .logger .info (
560- f"Uploaded file handle { file_handle .get ('id' )} for wiki page attachment ."
538+ f"Uploaded file handle { file_handle .get ('id' )} for wiki page markdown ."
561539 )
540+ # Set the markdown file handle ID from the upload response
541+ self .markdown_file_handle_id = file_handle .get ("id" )
542+ finally :
543+ # delete the temp gzip file
544+ os .remove (file_path )
545+ client .logger .debug (f"Deleted temp gzip file { file_path } " )
546+
547+ # Convert attachments to gzipped file if needed
548+ if self .attachments :
549+ try :
550+ file_handles = []
551+ for attachment in self .attachments :
552+ file_path = self ._to_gzip_file (
553+ wiki_content = attachment , synapse_client = client
554+ )
555+ file_handle = await upload_file_handle (
556+ syn = client ,
557+ parent_entity_id = self .owner_id ,
558+ path = file_path ,
559+ )
560+ file_handles .append (file_handle .get ("id" ))
561+ client .logger .info (
562+ f"Uploaded file handle { file_handle .get ('id' )} for wiki page attachment."
563+ )
564+ # Set the attachment file handle IDs from the upload response
565+ self .attachment_file_handle_ids = file_handles
566+ finally :
562567 # delete the temp gzip file
563568 os .remove (file_path )
564569 client .logger .debug (f"Deleted temp gzip file { file_path } " )
565- # Set the attachment file handle IDs from the upload response
566- self .attachment_file_handle_ids = file_handles
567570
568571 # Handle root wiki page creation if parent_id is not given
569572 if not self .parent_id :
0 commit comments