Skip to content

refactor: split GDriveConnection into a Drive client, layout, and one class per job - #9600

Merged
koenvanderveen merged 29 commits into
devfrom
pjwerneck/drive-client
Oct 30, 2026
Merged

koenvanderveen merged 29 commits into
devfrom
pjwerneck/drive-client

Conversation

@pjwerneck

Copy link
Copy Markdown
Collaborator

Summary

Third connsplit v1.1 PR: the Drive code moves out of GDriveConnection into a shared client, a folder layout and one class pertransport job, and this fixes the Drive bugs found along the way. Base: pjwerneck/drive-transport-fixes.

Changes

  • GDriveClient holds the Drive service and the raw calls (files, permissions, paged listing). DriveLayout holds syft's folder names, version rules and folder-id caches.
  • DriveOwnerStore, DriveCollections, DrivePeering and DriveP2PConnection now hold their job's Drive code under the contract names. GDriveConnection goes from 2,472 to about 450 lines: setup, message reading and account cleanup.
  • The router and syncers reach Drive only through the transport (transport_for_thread() for thread copies).
  • Fixes:
    • checkpoint and rolling-state calls retry
    • owner-state reads raise instead of mistaking a failed download for a missing file
    • peer-request and collection listings read every page
    • a merged incremental left behind by a failed delete no longer reverts files on restore or compaction
    • failed deletes and permission grants raise instead of being swallowed or matched by error text

Testing

  • Regression tests for each fix. Unit, syft-rds, syft-datasets, syft-enclave, syft-job, migrations and mock-mode integration suites pass.
  • Live harnesses on real Drive pass: the drive-transport-fixes scenarios, and 250 collections paged in three pages. The permission behavior was checked live: Drive answers a repeat share with 200.

Asana task

The batch callback ignored any error whose text contained "alreadyShared".
Tested live on real Drive: sharing a folder with a user who already has
access returns that permission with status 200, in single and batch
requests. Drive never sends an "alreadyShared" error, so the text check
could only hide real errors.
…eckpoint

Nothing called it: ConnectionRouter.get_events_count_since_checkpoint counts
through OwnerStore.count_events_since, which parses each event name. This
method matched the name prefix by hand instead, so the two could disagree.
Resolve the overlap with the transport PRs on dev (#9594, #9595, #9597, #9599):

- The manager builds the transport at init, as on dev. as_transport, the
  router's connection list and transport_for_thread are gone.
- Each Drive component holds the DriveLayout and its own Drive code, as on
  this branch.
- Each component copies itself for another thread with clone_for_thread, as
  on dev. The copy runs over a layout clone with a new Drive service, which
  GDriveClient builds with its new_service factory.
- Inbox and outbox reading move into DriveP2PConnection, with dev's parallel
  receive and batched archive. delete_all moves into DriveOwnerStore.
  GDriveConnection only logs in and builds the layout.
- Tests reach Drive through drive_layout_of(transport), which replaces
  gdrive_connection_of.
GDriveConnection only logged in and built the DriveCachedClient, so the
login constructors (from_config, from_token_path, from_service) now live on
DriveCachedClient and gdrive_transport.py is gone. build_drive_service and
SCOPES move to gdrive_client.py. SyftboxPlatformConnection and
GdriveConnectionConfig.connection_type had no other users and are removed.
@koenvanderveen
koenvanderveen marked this pull request as ready for review October 30, 2026 12:16
@koenvanderveen
koenvanderveen merged commit 41b7ef1 into dev Oct 30, 2026
21 checks passed
@koenvanderveen
koenvanderveen deleted the pjwerneck/drive-client branch October 30, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants