Skip to content

Create Drive directories in mkdir and makedirs - #409

Open
shcheklein wants to merge 11 commits into
fix/fs-directory-cache-invalidationfrom
fix/fs-create-directories
Open

shcheklein wants to merge 11 commits into
fix/fs-directory-cache-invalidationfrom
fix/fs-create-directories

Conversation

@shcheklein

@shcheklein shcheklein commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Fixes #349. This PR builds on #408.

PyDrive2 inherited fsspec's no-op directory creation methods. mkdir and makedirs now create real Drive folders and use the resolver from #408 to identify missing components, existing folders, and blocking files. Bare folder-ID mounts also check their Drive, MIME type and trash status.

Tests cover create_parents, exist_ok, duplicate names, shared drives and concurrent invalidation. They require one lookup and one create per missing component and zero requests for an already cached directory. A live Drive test verifies an empty nested directory from a fresh filesystem instance.

@shcheklein shcheklein left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-generated review of ae0d8572fbc4e3b35707c9ad19616388aa9b21b8.

Scope is well-bounded for #349, and the request-level + live tests are concise. Main findings inline: walking top-down from root misses self.base / cached ancestors (adding extra Drive calls for nested mounts like dvc-gdrive), relying on _get_cached_item_ids right after _get_remote_item_ids as a folder-vs-file side-channel will race once #408 lands, and not base makes an uncached self.info() call on every root-level makedirs(..., exist_ok=True).

Comment thread pydrive2/fs/spec.py Resolved
Comment thread pydrive2/fs/spec.py Resolved
Comment thread pydrive2/fs/spec.py Resolved
Comment thread pydrive2/fs/spec.py Resolved
@shcheklein
shcheklein changed the base branch from main to fix/fs-directory-cache-invalidation November 22, 2026 07:02

@shcheklein shcheklein left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-generated re-review of adb4a5cac8b6fb2611e927855fbbb622b9618bc7 (from scratch).

The bottom-up ancestor walk (missing), direct _named_items folder filtering (removing the cache side-channel), and _mount_directory_ids() filtering are all much cleaner and resolve the earlier issues.

Two remaining things flagged inline: an unlocked read/write race on self._directory_ids / root_cache["root_is_directory"], and duplication between root_is_directory here and _root_location in #411.

Comment thread pydrive2/fs/spec.py Resolved
Comment thread pydrive2/fs/spec.py Resolved
@shcheklein

Copy link
Copy Markdown
Member Author

Directory creation now uses the path resolver from #408. It handles named mounts, exact-case matches and multiple folder IDs once. mkdir and makedirs apply the creation rules for missing parents, a blocking file and exist_ok to those results.

The request tests still require one lookup and one create per missing folder, zero requests for an already cached folder, and one lookup when a file blocks creation at a named mount. This PR continues to target #408.

This branch has not been deployed

No deployments
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.

fs.makedirs() fails unless you put a file in the folder (shared drive)

1 participant