Skip to content

Allow listing an empty drive root#64

Open
gaoflow wants to merge 2 commits into
fsspec:masterfrom
gaoflow:fix-59-empty-root-ls
Open

Allow listing an empty drive root#64
gaoflow wants to merge 2 commits into
fsspec:masterfrom
gaoflow:fix-59-empty-root-ls

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • treat an empty top-level Drive listing as an empty directory instead of a missing path
  • keep FileNotFoundError for missing non-root paths
  • add unit tests for both paths

Tests

  • .venv/bin/python -m pytest -q
  • .venv/bin/pre-commit run --files gdrive_fsspec/core.py tests/test_core.py

Fixes #59

AI assistance was used under my direction.

@martindurant

Copy link
Copy Markdown
Member

What happens if the drive in question doesn't exist at all? I would expect FileNotFound rather than an empty listing.

@gaoflow gaoflow force-pushed the fix-59-empty-root-ls branch from ed56d6f to 01ede5e Compare June 19, 2026 19:45
@gaoflow

gaoflow commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Good point. I updated the branch so the empty-root case and missing-root case are distinct.

Current behavior after 01ede5e:

  • ls("") on an existing but empty default/root folder still returns [].
  • ls("") with a custom root_file_id that exists but has no children still returns [].
  • ls("") with a custom root_file_id whose listing is empty and whose id cannot be resolved now raises FileNotFoundError instead of caching/returning an empty listing.

I also rebased the branch onto the latest master, which should resolve the dirty merge state.

Verification:

.venv/bin/python -m pytest tests/test_core.py -q
# 31 passed, 2 deselected in 0.06s

.venv/bin/python -m pytest -q
# 31 passed, 2 deselected in 0.06s

ruff check gdrive_fsspec/core.py tests/test_core.py
# All checks passed!

ruff format --check gdrive_fsspec/core.py tests/test_core.py
# 2 files already formatted

git diff --check origin/master...HEAD
# no output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ls("") raises FileNotFoundError on an empty drive

2 participants