refactor: Use _make_request where available
This commit is contained in:
@@ -126,7 +126,7 @@ class WebDAVClient(BaseNextcloudClient):
|
|||||||
# First check if we can access WebDAV at all
|
# First check if we can access WebDAV at all
|
||||||
notes_dir_path = f"{webdav_base}/Notes"
|
notes_dir_path = f"{webdav_base}/Notes"
|
||||||
propfind_headers = {"Depth": "0", "OCS-APIRequest": "true"}
|
propfind_headers = {"Depth": "0", "OCS-APIRequest": "true"}
|
||||||
notes_dir_response = await self._client.request(
|
notes_dir_response = await self._make_request(
|
||||||
"PROPFIND", notes_dir_path, headers=propfind_headers
|
"PROPFIND", notes_dir_path, headers=propfind_headers
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ class WebDAVClient(BaseNextcloudClient):
|
|||||||
|
|
||||||
# Ensure the parent directory exists using MKCOL
|
# Ensure the parent directory exists using MKCOL
|
||||||
mkcol_headers = {"OCS-APIRequest": "true"}
|
mkcol_headers = {"OCS-APIRequest": "true"}
|
||||||
mkcol_response = await self._client.request(
|
mkcol_response = await self._make_request(
|
||||||
"MKCOL", parent_dir_path, headers=mkcol_headers
|
"MKCOL", parent_dir_path, headers=mkcol_headers
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -157,8 +157,8 @@ class WebDAVClient(BaseNextcloudClient):
|
|||||||
mkcol_response.raise_for_status()
|
mkcol_response.raise_for_status()
|
||||||
|
|
||||||
# Proceed with the PUT request
|
# Proceed with the PUT request
|
||||||
response = await self._client.put(
|
response = await self._make_request(
|
||||||
attachment_path, content=content, headers=headers
|
"PUT", attachment_path, content=content, headers=headers
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
logger.debug(
|
logger.debug(
|
||||||
@@ -189,7 +189,7 @@ class WebDAVClient(BaseNextcloudClient):
|
|||||||
logger.debug(f"Fetching attachment '{filename}' for note {note_id}")
|
logger.debug(f"Fetching attachment '{filename}' for note {note_id}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = await self._client.get(attachment_path)
|
response = await self._make_request("GET", attachment_path)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
content = response.content
|
content = response.content
|
||||||
@@ -236,7 +236,7 @@ class WebDAVClient(BaseNextcloudClient):
|
|||||||
headers = {"Depth": "1", "Content-Type": "text/xml", "OCS-APIRequest": "true"}
|
headers = {"Depth": "1", "Content-Type": "text/xml", "OCS-APIRequest": "true"}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = await self._client.request(
|
response = await self._make_request(
|
||||||
"PROPFIND", webdav_path, content=propfind_body, headers=headers
|
"PROPFIND", webdav_path, content=propfind_body, headers=headers
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
@@ -319,7 +319,7 @@ class WebDAVClient(BaseNextcloudClient):
|
|||||||
logger.debug(f"Reading file: {path}")
|
logger.debug(f"Reading file: {path}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = await self._client.get(webdav_path)
|
response = await self._make_request("GET", webdav_path)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
content = response.content
|
content = response.content
|
||||||
@@ -353,8 +353,8 @@ class WebDAVClient(BaseNextcloudClient):
|
|||||||
headers = {"Content-Type": content_type, "OCS-APIRequest": "true"}
|
headers = {"Content-Type": content_type, "OCS-APIRequest": "true"}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = await self._client.put(
|
response = await self._make_request(
|
||||||
webdav_path, content=content, headers=headers
|
"PUT", webdav_path, content=content, headers=headers
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
@@ -381,7 +381,7 @@ class WebDAVClient(BaseNextcloudClient):
|
|||||||
headers = {"OCS-APIRequest": "true"}
|
headers = {"OCS-APIRequest": "true"}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = await self._client.request("MKCOL", webdav_path, headers=headers)
|
response = await self._make_request("MKCOL", webdav_path, headers=headers)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
logger.debug(f"Successfully created directory '{path}'")
|
logger.debug(f"Successfully created directory '{path}'")
|
||||||
|
|||||||
Reference in New Issue
Block a user