From b7b5d2d98bdaf777c2e659c2dad21896043fb474 Mon Sep 17 00:00:00 2001 From: shindeakshay0211 Date: Tue, 30 Sep 2025 12:03:27 +0530 Subject: [PATCH 1/2] Fix: ensure dbutils.fs.ls lists directories with trailing '/' --- databricks/sdk/mixins/files.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/databricks/sdk/mixins/files.py b/databricks/sdk/mixins/files.py index 2cdaf3532..530a7c6b5 100644 --- a/databricks/sdk/mixins/files.py +++ b/databricks/sdk/mixins/files.py @@ -404,16 +404,24 @@ def list(self, recursive=False) -> Generator[files.FileInfo, None, None]: path = queue.popleft() for leaf in path.iterdir(): if leaf.is_dir(): + # Yield directory info, path ends with '/' + info = leaf.stat() + yield files.FileInfo( + path="file:" + str(leaf.absolute()) + "/", + is_dir=True, + file_size=0, + modification_time=int(info.st_mtime_ns / 1e6), + ) if recursive: queue.append(leaf) - continue - info = leaf.stat() - yield files.FileInfo( - path="file:" + str(leaf.absolute()), - is_dir=False, - file_size=info.st_size, - modification_time=int(info.st_mtime_ns / 1e6), - ) + else: + info = leaf.stat() + yield files.FileInfo( + path="file:" + str(leaf.absolute()), + is_dir=False, + file_size=info.st_size, + modification_time=int(info.st_mtime_ns / 1e6), + ) def delete(self, *, recursive=False): if self.is_dir: From 1c19997d463636e6d98e14da265498ab0e5fe8d7 Mon Sep 17 00:00:00 2001 From: shindeakshay0211 Date: Tue, 30 Sep 2025 12:15:42 +0530 Subject: [PATCH 2/2] Fix: ensure dbutils.fs.ls lists directories with trailing '/' and and update changelog --- NEXT_CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index b4585a98d..d82292988 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -6,6 +6,8 @@ ### Bug Fixes +- Fixed local directory listing to include folders as well as files. Directory paths now end with '/' and are correctly marked as directories. + ### Documentation ### Internal Changes