From 7a26457160499e45f047a2ae3a593fb90f3178d3 Mon Sep 17 00:00:00 2001 From: Anne-Sophie Tonneau Date: Wed, 11 Jun 2025 14:13:41 +0000 Subject: [PATCH 1/2] feat: new option for local file system to follow symbolic links --- fsspec/implementations/local.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fsspec/implementations/local.py b/fsspec/implementations/local.py index 70dfd901e..b980257b7 100644 --- a/fsspec/implementations/local.py +++ b/fsspec/implementations/local.py @@ -30,10 +30,12 @@ class LocalFileSystem(AbstractFileSystem): root_marker = "/" protocol = "file", "local" local_file = True + follow_symlinks: bool - def __init__(self, auto_mkdir=False, **kwargs): + def __init__(self, auto_mkdir=False, follow_symlinks=False, **kwargs): super().__init__(**kwargs) self.auto_mkdir = auto_mkdir + self.follow_symlinks = follow_symlinks @property def fsid(self): @@ -78,11 +80,11 @@ def ls(self, path, detail=False, **kwargs): def info(self, path, **kwargs): if isinstance(path, os.DirEntry): # scandir DirEntry - out = path.stat(follow_symlinks=False) + out = path.stat(follow_symlinks=self.follow_symlinks) link = path.is_symlink() - if path.is_dir(follow_symlinks=False): + if path.is_dir(follow_symlinks=self.follow_symlinks): t = "directory" - elif path.is_file(follow_symlinks=False): + elif path.is_file(follow_symlinks=self.follow_symlinks): t = "file" else: t = "other" From 213219e1db43825dc2346327e01c4d6892bf61f6 Mon Sep 17 00:00:00 2001 From: Anne-Sophie Tonneau Date: Wed, 11 Jun 2025 14:17:44 +0000 Subject: [PATCH 2/2] doc: docstring --- fsspec/implementations/local.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fsspec/implementations/local.py b/fsspec/implementations/local.py index b980257b7..fc788a6dc 100644 --- a/fsspec/implementations/local.py +++ b/fsspec/implementations/local.py @@ -25,6 +25,8 @@ class LocalFileSystem(AbstractFileSystem): Whether, when opening a file, the directory containing it should be created (if it doesn't already exist). This is assumed by pyarrow code. + follow_symlinks: bool + follow symbolic links (default: False) """ root_marker = "/"