Skip to content

Commit

Permalink
Fix ls
Browse files Browse the repository at this point in the history
- Fix bag: return empty list if contain one directory
- Fix bag: return empty list when _ls_from_cache have not cache but have key
  • Loading branch information
renesat committed Jan 27, 2024
1 parent 8a53184 commit fe8fc1a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lakefs_spec/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def _ls_from_cache(self, path: str, recursive: bool = False) -> list[dict[str, A
result = []
result.extend(files)
if not result:
return result
return None
return sorted(result, key=operator.itemgetter("name"))

@overload
Expand Down Expand Up @@ -542,7 +542,7 @@ def ls(
# Retry the API call with appended slash if the current result
# is just a single directory entry only (not its contents).
# This is useful to allow `ls("repo/branch/dir")` calls without a trailing slash.
if len(info) == 1 and info[0]["type"] == "directory":
if len(info) == 1 and info[0]["type"] == "directory" and info[0]["name"] == path + "/":
return self.ls(
path + "/",
detail=detail,
Expand Down

0 comments on commit fe8fc1a

Please sign in to comment.