Skip to content

Commit 0a5f2e6

Browse files
committed
update markdown name if it's created from text to make it more informative
1 parent 43bb9a0 commit 0a5f2e6

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

synapseclient/models/wiki.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -98,59 +98,59 @@ def to_synapse_request(self) -> Dict[str, List[str]]:
9898
return result
9999

100100
@otel_trace_method(
101-
method_to_trace_name=lambda self, **kwargs: f"Get_Wiki_Order_Hint: {self.owner_id}"
101+
method_to_trace_name=lambda self, **kwargs: f"Store_Wiki_Order_Hint: {self.owner_id}"
102102
)
103-
async def get_async(
103+
async def store_async(
104104
self,
105105
*,
106106
synapse_client: Optional["Synapse"] = None,
107107
) -> "WikiOrderHint":
108108
"""
109-
Get the order hint of a wiki page tree.
109+
Store the order hint of a wiki page tree.
110110
111111
Arguments:
112112
synapse_client: Optionally provide a Synapse client.
113113
Returns:
114-
A WikiOrderHint object for the entity.
114+
The updated WikiOrderHint object for the entity.
115115
Raises:
116-
ValueError: If owner_id is not provided.
116+
ValueError: If owner_id or request is not provided.
117117
"""
118118
if not self.owner_id:
119-
raise ValueError("Must provide owner_id to get wiki order hint.")
120-
order_hint_dict = await get_wiki_order_hint(
119+
raise ValueError("Must provide owner_id to store wiki order hint.")
120+
121+
order_hint_dict = await put_wiki_order_hint(
121122
owner_id=self.owner_id,
123+
request=self.to_synapse_request(),
122124
synapse_client=synapse_client,
123125
)
124-
return self.fill_from_dict(order_hint_dict)
126+
self.fill_from_dict(order_hint_dict)
127+
return self
125128

126129
@otel_trace_method(
127-
method_to_trace_name=lambda self, **kwargs: f"Update_Wiki_Order_Hint: {self.owner_id}"
130+
method_to_trace_name=lambda self, **kwargs: f"Get_Wiki_Order_Hint: {self.owner_id}"
128131
)
129-
async def store_async(
132+
async def get_async(
130133
self,
131134
*,
132135
synapse_client: Optional["Synapse"] = None,
133136
) -> "WikiOrderHint":
134137
"""
135-
Store the order hint of a wiki page tree.
138+
Get the order hint of a wiki page tree.
136139
137140
Arguments:
138141
synapse_client: Optionally provide a Synapse client.
139142
Returns:
140-
The updated WikiOrderHint object for the entity.
143+
A WikiOrderHint object for the entity.
141144
Raises:
142-
ValueError: If owner_id or request is not provided.
145+
ValueError: If owner_id is not provided.
143146
"""
144147
if not self.owner_id:
145-
raise ValueError("Must provide owner_id to store wiki order hint.")
146-
147-
order_hint_dict = await put_wiki_order_hint(
148+
raise ValueError("Must provide owner_id to get wiki order hint.")
149+
order_hint_dict = await get_wiki_order_hint(
148150
owner_id=self.owner_id,
149-
request=self.to_synapse_request(),
150151
synapse_client=synapse_client,
151152
)
152-
self.fill_from_dict(order_hint_dict)
153-
return self
153+
return self.fill_from_dict(order_hint_dict)
154154

155155

156156
@dataclass
@@ -471,7 +471,7 @@ def _to_gzip_file(
471471

472472
else:
473473
# If it's a plain text, write it to a gzipped file and save it in the synapse cache
474-
file_path = os.path.join(cache_dir, f"wiki_markdown_{self.id}.md.gz")
474+
file_path = os.path.join(cache_dir, f"wiki_markdown_{self.title}.md.gz")
475475
with gzip.open(file_path, "wt", encoding="utf-8") as f_out:
476476
f_out.write(wiki_content)
477477

@@ -970,6 +970,7 @@ async def get_markdown_async(
970970
Get the markdown URL of this wiki page.
971971
972972
Arguments:
973+
download_file_name: The name of the file to download. Required if download_file is True.
973974
download_file: Whether associated files should be downloaded. Default is True.
974975
download_location: The directory to download the file to. Required if download_file is True.
975976
redirect: When set to false, the URL will be returned as text/plain instead of redirecting. Default is False.

0 commit comments

Comments
 (0)