Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
nunogoncalves03 committed Nov 26, 2024
1 parent ac1f030 commit 62fdfe2
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions singlestoredb/management/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,9 +847,12 @@ def is_dir(self, path: PathLike) -> bool:
bool
"""
raise ValueError(
'Operation not supported: directories are currently not allowed in Files API',
)
try:
return self.info(path).type == 'directory'
except ManagementError as exc:
if exc.errno == 404:
return False
raise

# TODO: remove from FileLocation?
def is_file(self, path: PathLike) -> bool:
Expand All @@ -873,6 +876,19 @@ def is_file(self, path: PathLike) -> bool:
return False
raise

def _list_root_dir(self) -> List[str]:
"""
Return the names of files in the root directory.
Parameters
----------
"""
res = self._manager._get(
f'files/fs/{self._location}',
).json()
return [x['path'] for x in res['content'] or []]

# TODO: remove from FileLocation?
def listdir(
self,
Expand All @@ -893,6 +909,9 @@ def listdir(
List[str]
"""
if path == '/':
return self._list_root_dir()

raise ValueError(
'Operation not supported: directories are currently not allowed in Files API',
)
Expand Down

0 comments on commit 62fdfe2

Please sign in to comment.