`LocalStore.head()` fails for existing local folders in Windows - making `FsspecStore.exists()`, `FsspecStore.rm()` fail too

Open
#555 16 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python, rust

Research direction

Start at FsspecStore._info, the entry point shown in the traceback, and trace how LocalStore.head handles the Windows path C:/dev. Reproduce the existing-folder case on Windows, then verify that exists() and rm() work for local directories without regressing file and missing-path behavior.

Written by the indexing model from the issue text.

Description

Hi,
I noticed the following bug when working with local Windows URL-style paths:

✅ works fine
import fsspec

fs_fsspec = fsspec.filesystem("file")
fs_fsspec.exists("C:/dev/some.txt")  # ✅ file does actually exist
fs_fsspec.exists("C:/dev/foo.txt")  # ✅ file does not actually exist
fs_fsspec.exists("C:/dev/tmp")  # ✅ folder does not actually exist
fs_fsspec.exists("C:/dev")  # ✅ folder does actually exist
❌ fails
from obstore.fsspec import FsspecStore

fs_fsspecstore = FsspecStore("file")
fs_fsspecstore.exists("C:/dev/some.txt")  # ✅ file does actually exist
fs_fsspecstore.exists("C:/dev/foo.txt")  # ✅ file does not actually exist
fs_fsspecstore.exists("C:/dev/tmp")  # ✅ folder does not actually exist
fs_fsspecstore.exists("C:/dev")  # ❌ folder does actually exist
---------------------------------------------------------------------------
GenericError                              Traceback (most recent call last)
Cell In[28], line 5
      3 fs_fsspecstore.exists("C:/dev/foo.txt")  # file does not actually exist
      4 fs_fsspecstore.exists("C:/dev/tmp")  # folder does nor actually exist
----> 5 fs_fsspecstore.exists("C:/dev")  # folder does actually exist

File c:\Users\...\.venv\lib\site-packages\fsspec\asyn.py:118, in sync_wrapper.<locals>.wrapper(*args, **kwargs)
    115 @functools.wraps(func)
    116 def wrapper(*args, **kwargs):
    117     self = obj or args[0]
--> 118     return sync(self.loop, func, *args, **kwargs)

File c:\Users\...\.venv\lib\site-packages\fsspec\asyn.py:103, in sync(loop, func, timeout, *args, **kwargs)
    101     raise FSTimeoutError from return_result
    102 elif isinstance(return_result, BaseException):
--> 103     raise return_result
    104 else:
    105     return return_result

File c:\Users\...\.venv\lib\site-packages\fsspec\asyn.py:56, in _runner(event, coro, result, timeout)
     54     coro = asyncio.wait_for(coro, timeout=timeout)
     55 try:
---> 56     result[0] = await coro
     57 except Exception as ex:
     58     result[0] = ex

File c:\Users\...\.venv\lib\site-packages\fsspec\asyn.py:695, in AsyncFileSystem._exists(self, path, **kwargs)
    693 async def _exists(self, path, **kwargs):
    694     try:
--> 695         await self._info(path, **kwargs)
    696         return True
    697     except FileNotFoundError:

File c:\Users\...\.venv\lib\site-packages\obstore\fsspec.py:503, in FsspecStore._info(self, path, **_kwargs)
    500 store = self._construct_store(bucket)
    502 try:
--> 503     head = await obs.head_async(store, path_no_bucket)
    504     return {
    505         # Required of `info`: (?)
    506         "name": head["path"],
   (...)
    512         "version": head["version"],
    513     }
    514 except FileNotFoundError:

GenericError: Generic LocalFileSystem error: Unable to open file C:\dev: Zugriff verweigert (os error 5)

Debug source:
Generic {
    store: "LocalFileSystem",
    source: UnableToOpenFile {
        source: Os {
            code: 5,
            kind: PermissionDenied,
            message: "Zugriff verweigert",
        },
        path: "C:\\dev",
    },
}
Dominant language
Python
Stars
842
Forks
50
Avg merge
9h
Merged PRs (30d)
13

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from developmentseed/obstore

All issues in developmentseed/obstore

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.