Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ex_app/lib/all_tools/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ async def get_file_content(file_path: str):
"Content-Type": "application/json",
})

response.raise_for_status()
return response.text

@tool
Expand Down Expand Up @@ -156,6 +157,7 @@ async def upload_file(path: str, content: str):
"Content-Type": "text/plain",
}, data=content)

response.raise_for_status()
return {"status": "success", "path": path}

@tool
Expand All @@ -173,6 +175,7 @@ async def create_folder(path: str):
"Content-Type": "application/json",
})

response.raise_for_status()
return {"status": "success", "path": path}

@tool
Expand All @@ -193,6 +196,7 @@ async def move_file(source_path: str, destination_path: str):
"Destination": f"{nc.app_cfg.endpoint}/remote.php/dav/files/{user_id}/{destination_path}",
})

response.raise_for_status()
return {"status": "success", "from": source_path, "to": destination_path}

@tool
Expand All @@ -213,6 +217,7 @@ async def copy_file(source_path: str, destination_path: str):
"Destination": f"{nc.app_cfg.endpoint}/remote.php/dav/files/{user_id}/{destination_path}",
})

response.raise_for_status()
return {"status": "success", "from": source_path, "to": destination_path}

@tool
Expand All @@ -237,6 +242,7 @@ async def get_file_id_by_path(file_path: str) -> int:
headers={"Content-Type": "application/xml; charset=utf-8", "Depth": "0"},
data=propfind_body,
)
propfind_response.raise_for_status()

root = ET.fromstring(propfind_response.text)
fileid_element = root.find(".//{http://owncloud.org/ns}fileid")
Expand Down Expand Up @@ -276,6 +282,7 @@ async def get_file_path_by_id(file_id: int) -> str:
headers={"Content-Type": "text/xml; charset=utf-8"},
data=search_body,
)
search_response.raise_for_status()

root = ET.fromstring(search_response.text)
href_element = root.find(".//{DAV:}response/{DAV:}href")
Expand Down Expand Up @@ -313,6 +320,7 @@ async def convert_file(source_path: str, target_mime_type: str, destination_path
headers={"Content-Type": "application/xml; charset=utf-8", "Depth": "0"},
data=propfind_body,
)
propfind_response.raise_for_status()

root = ET.fromstring(propfind_response.text)
fileid_element = root.find(".//{http://owncloud.org/ns}fileid")
Expand Down Expand Up @@ -347,6 +355,7 @@ async def delete_file(path: str):
"Content-Type": "application/json",
})

response.raise_for_status()
return {"status": "success", "deleted": path}

return [
Expand Down
Loading