AlenkaF commented on code in PR #37558:
URL: https://github.com/apache/arrow/pull/37558#discussion_r1322612126


##########
python/pyarrow/fs.py:
##########
@@ -356,7 +356,12 @@ def get_file_info_selector(self, selector):
             selector.base_dir, maxdepth=maxdepth, withdirs=True, detail=True
         )
         for path, info in selected_files.items():
-            infos.append(self._create_file_info(path, info))
+            # Need to exclude base directory from selected files if present
+            # (fsspec filesystems, see GH-37555)
+            if (path != selector.base_dir and
+                path != "/" + selector.base_dir[:len(selector.base_dir)-1] and
+                    path != selector.base_dir[:len(selector.base_dir)-1]):

Review Comment:
   Unfortunately starting/ending slashes also change in the `path` - I have 
forgot about that.
   
   - for `fsspec.LocalFileSystem()` the `path` and `base_dir` are equal: 
'/.../test_get_file_info_with_select0/selector-dir'
   - for `fsspec.filesystem("memory")` the `path` and `base_dir` differ like 
so: '/selector-dir' vs 'selector-dir/'
   - for `s3fs.S3FileSystem()` the `path` and `base_dir` differ like so: 
'pyarrow-filesystem/selector-dir' vs 'pyarrow-filesystem/selector-dir/'
   
   I could read with start/end for both paths, if you still feel it will be 
clearer?
   
   ```python
   ```



##########
python/pyarrow/fs.py:
##########
@@ -356,7 +356,12 @@ def get_file_info_selector(self, selector):
             selector.base_dir, maxdepth=maxdepth, withdirs=True, detail=True
         )
         for path, info in selected_files.items():
-            infos.append(self._create_file_info(path, info))
+            # Need to exclude base directory from selected files if present
+            # (fsspec filesystems, see GH-37555)
+            if (path != selector.base_dir and
+                path != "/" + selector.base_dir[:len(selector.base_dir)-1] and
+                    path != selector.base_dir[:len(selector.base_dir)-1]):

Review Comment:
   Unfortunately starting/ending slashes also change in the `path` - I have 
forgot about that.
   
   - for `fsspec.LocalFileSystem()` the `path` and `base_dir` are equal: 
'/.../test_get_file_info_with_select0/selector-dir'
   - for `fsspec.filesystem("memory")` the `path` and `base_dir` differ like 
so: '/selector-dir' vs 'selector-dir/'
   - for `s3fs.S3FileSystem()` the `path` and `base_dir` differ like so: 
'pyarrow-filesystem/selector-dir' vs 'pyarrow-filesystem/selector-dir/'
   
   I could read with start/end for both paths, if you still feel it will be 
clearer?
   
   ```python
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to