file_manager: add list roots endpoint

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2022-10-30 16:39:01 -04:00
parent 130c2a48f0
commit e8dad1c8c0
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
1 changed files with 15 additions and 0 deletions

View File

@ -86,6 +86,8 @@ class FileManager:
"/server/files/list", ['GET'], self._handle_filelist_request) "/server/files/list", ['GET'], self._handle_filelist_request)
self.server.register_endpoint( self.server.register_endpoint(
"/server/files/metadata", ['GET'], self._handle_metadata_request) "/server/files/metadata", ['GET'], self._handle_metadata_request)
self.server.register_endpoint(
"/server/files/roots", ['GET'], self._handle_list_roots)
self.server.register_endpoint( self.server.register_endpoint(
"/server/files/directory", ['GET', 'POST', 'DELETE'], "/server/files/directory", ['GET', 'POST', 'DELETE'],
self._handle_directory_request) self._handle_directory_request)
@ -334,6 +336,19 @@ class FileManager:
metadata['filename'] = requested_file metadata['filename'] = requested_file
return metadata return metadata
async def _handle_list_roots(
self, web_request: WebRequest
) -> List[Dict[str, Any]]:
root_list: List[Dict[str, Any]] = []
for name, path in self.file_paths.items():
perms = "rw" if name in self.full_access_roots else "r"
root_list.append({
"name": name,
"path": path,
"permissions": perms
})
return root_list
async def _handle_directory_request(self, async def _handle_directory_request(self,
web_request: WebRequest web_request: WebRequest
) -> Dict[str, Any]: ) -> Dict[str, Any]: