From fe8fc1a898755b0f83d2aeffaf65bbfe757fc02c Mon Sep 17 00:00:00 2001 From: renesat Date: Sat, 27 Jan 2024 18:32:14 +0100 Subject: [PATCH] Fix ls - Fix bag: return empty list if contain one directory - Fix bag: return empty list when _ls_from_cache have not cache but have key --- src/lakefs_spec/spec.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lakefs_spec/spec.py b/src/lakefs_spec/spec.py index 82cae4fa..b906ecf8 100644 --- a/src/lakefs_spec/spec.py +++ b/src/lakefs_spec/spec.py @@ -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 @@ -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,