You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "AlphaJack (via GitHub)" <gi...@apache.org> on 2026/10/15 15:18:00 UTC

[PR] feat(services/gdrive): support shared drives [opendal]

AlphaJack opened a new pull request, #8410:
URL: https://github.com/apache/opendal/pull/8410

   # Which issue does this PR close?
   
   Closes #4576.
   
   # Rationale for this change
   
   The gdrive service only works inside the authenticated user's My Drive. `GdrivePathQuery::root` always returns the `root` alias, and no request sends `supportsAllDrives=true`, so Drive API v3 returns 404 for shared drive items.
   
   This PR replaces #4591, which targets the pre-split layout (`core/src/services/gdrive`) and changes only the list request. It builds on the findings from that thread: Google rejects `driveId` without `includeItemsFromAllDrives=true`, and reonokiy's branch showed that using the drive ID as the root folder ID works against a real shared drive. 
   
   # What changes are included in this PR?
   
   - Add `drive_id` to `GdriveConfig` and a `Gdrive::drive_id()` builder method.
   - Use `drive_id` as the root folder ID when it is set. The ID of a shared drive is also the ID of its top-level folder.
   - Send `supportsAllDrives=true` on every `files.*` request: get, media download, create, multipart and media upload, update (rename and trash), and copy.
   - Send `includeItemsFromAllDrives=true` on every `files.list` request (single directory, batched recursive listing, and path lookup), and add `corpora=drive&driveId=<drive_id>` when `drive_id` is set.
   - Document the option, the required shared drive roles, and a builder example in `docs.md`.
   - Regenerate the Python, Java, and .NET binding configs.
   
   The parameters follow Google's [shared drive guide](https://developers.google.com/workspace/drive/api/guides/enable-shareddrives) and match rclone's `team_drive` implementation.
   
   # Are there any user-facing changes?
   
   Yes. The gdrive service accepts a new optional `drive_id` config key. When it is set, `root` resolves inside that shared drive.
   
   Without `drive_id`, paths still resolve inside My Drive.
   Requests now always include `supportsAllDrives=true`, and list requests always include `includeItemsFromAllDrives=true`. Every list query is scoped to a parent folder, so these flags do not change My Drive results.
   
   Delete, rename, and copy onto an existing path trash or move items, which requires the Content manager role or higher on the shared drive.
   
   # Breaking changes
   
   None.
   
   # Testing
   
   - Added a unit test that `drive_id` is parsed from the URI options.
   - All tests pass
   
   `/opendal/core/.env`
   ```dotenv
   OPENDAL_GDRIVE_ROOT=/test-opendal/
   
   # tested both with (Shared Drive) and without (My Drive)
   OPENDAL_GDRIVE_DRIVE_ID=XXXXXX
   
   # short lived
   #OPENDAL_GDRIVE_ACCESS_TOKEN=XXXXXX
   
   # long lived
   OPENDAL_GDRIVE_REFRESH_TOKEN=XXXXXX
   OPENDAL_GDRIVE_CLIENT_ID=XXXXXX
   OPENDAL_GDRIVE_CLIENT_SECRET=XXXXXX
   ```
   
   `OPENDAL_TEST=gdrive cargo test behavior --features tests,services-gdrive`
   ```
   running 0 tests
   
   test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
   
        Running tests/behavior/main.rs (target/debug/deps/behavior-82b924a72e256466)
   
   running 128 tests
   test behavior::test_copy_non_existing_source                      ... ok
   test behavior::test_copy_source_dir                               ... ok
   test behavior::test_copy_self                                     ... ok
   test behavior::test_copy_file_with_non_ascii_name                 ... ok
   test behavior::test_copy_file_with_ascii_name                     ... ok
   test behavior::test_create_dir                                    ... ok
   test behavior::test_copy_target_dir                               ... ok
   test behavior::test_copier_completion                             ... ok
   test behavior::test_copier_file                                   ... ok
   test behavior::test_create_dir_existing                           ... ok
   test behavior::test_delete_stream                                 ... ok
   test behavior::test_copy_nested                                   ... ok
   test behavior::test_delete_with_version                           ... ok
   test behavior::test_delete_with_not_existing_version              ... ok
   test behavior::test_batch_delete                                  ... ok
   test behavior::test_batch_delete_with_version                     ... ok
   test behavior::test_delete_empty_dir                              ... ok
   test behavior::test_delete_file                                   ... ok
   test behavior::test_copy_overwrite                                ... ok
   test behavior::test_copier_abort                                  ... ok
   test behavior::test_check                                         ... ok
   test behavior::test_list_rich_dir                                 ... ok
   test behavior::test_delete_with_special_chars                     ... ok
   test behavior::test_list_non_exist_dir                            ... ok
   test behavior::test_list_empty_dir                                ... ok
   test behavior::test_list_sub_dir                                  ... ok
   test behavior::test_list_prefix                                   ... ok
   test behavior::test_list_with_start_after                         ... ok
   test behavior::test_list_dir                                      ... ok
   test behavior::test_delete_not_existing                           ... ok
   test behavior::test_list_non_exist_dir_with_recursive             ... ok
   test behavior::test_remove_one_file                               ... ok
   test behavior::test_list_dir_with_file_path                       ... ok
   test behavior::test_list_root_with_recursive                      ... ok
   test behavior::test_list_files_with_versions                      ... ok
   test behavior::test_list_with_versions_and_limit                  ... ok
   test behavior::test_list_with_versions_and_start_after            ... ok
   test behavior::test_list_files_with_deleted                       ... ok
   test behavior::test_delete_with_recursive_basic                   ... ok
   test behavior::test_remove_all_basic                              ... ok
   test behavior::test_read_full                                     ... ok
   test behavior::test_list_file_with_recursive                      ... ok
   test behavior::test_read_range                                    ... ok
   test behavior::test_list_nested_dir                               ... ok
   test behavior::test_buffer_stream_metadata                        ... ok
   test behavior::test_reader_with_if_match                          ... ok
   test behavior::test_reader_with_if_none_match                     ... ok
   test behavior::test_reader_with_if_modified_since                 ... ok
   test behavior::test_reader_with_if_unmodified_since               ... ok
   test behavior::test_buffer_stream_metadata_with_concurrent        ... ok
   test behavior::test_read_with_if_match                            ... ok
   test behavior::test_read_with_if_none_match                       ... ok
   test behavior::test_read_with_version_conditions                  ... ok
   test behavior::test_read_with_if_modified_since                   ... ok
   test behavior::test_read_with_if_unmodified_since                 ... ok
   test behavior::test_reader                                        ... ok
   test behavior::test_futures_bytes_stream_metadata_with_concurrent ... ok
   test behavior::test_read_with_override_cache_control              ... ok
   test behavior::test_read_with_override_content_disposition        ... ok
   test behavior::test_read_with_override_content_type               ... ok
   test behavior::test_read_with_version                             ... ok
   test behavior::test_read_with_not_existing_version                ... ok
   test behavior::test_read_not_exist                                ... ok
   test behavior::test_read_with_dir_path                            ... ok
   test behavior::test_read_suffix                                   ... ok
   test behavior::test_futures_bytes_stream_metadata                 ... ok
   test behavior::test_read_suffix_zero                              ... ok
   test behavior::test_read_suffix_larger_than_file                  ... ok
   test behavior::test_rename_source_dir                             ... ok
   test behavior::test_rename_non_existing_source                    ... ok
   test behavior::test_read_with_special_chars                       ... ok
   test behavior::test_reader_suffix_with_chunk                      ... ok
   test behavior::test_remove_all                                    ... ok
   test behavior::test_rename_target_dir                             ... ok
   test behavior::test_stat_dir                                      ... ok
   test behavior::test_rename_self                                   ... ok
   test behavior::test_list_dir_with_recursive                       ... ok
   test behavior::test_rename_nested                                 ... ok
   test behavior::test_stat_with_special_chars                       ... ok
   test behavior::test_stat_with_if_match                            ... ok
   test behavior::test_stat_with_if_none_match                       ... ok
   test behavior::test_stat_with_version_conditions                  ... ok
   test behavior::test_stat_with_if_modified_since                   ... ok
   test behavior::test_stat_with_if_unmodified_since                 ... ok
   test behavior::test_stat_with_override_cache_control              ... ok
   test behavior::test_stat_with_override_content_disposition        ... ok
   test behavior::test_stat_with_override_content_type               ... ok
   test behavior::test_stat_root                                     ... ok
   test behavior::test_stat_with_version                             ... ok
   test behavior::stat_with_not_existing_version                     ... ok
   test behavior::test_stat_nested_parent_dir                        ... ok
   test behavior::test_write_with_empty_content                      ... ok
   test behavior::test_write_with_dir_path                           ... ok
   test behavior::test_stat_not_cleaned_path                         ... ok
   test behavior::test_write_with_cache_control                      ... ok
   test behavior::test_write_with_content_type                       ... ok
   test behavior::test_write_with_content_disposition                ... ok
   test behavior::test_write_with_content_encoding                   ... ok
   test behavior::test_write_with_if_none_match                      ... ok
   test behavior::test_write_with_if_not_exists                      ... ok
   test behavior::test_write_with_if_match                           ... ok
   test behavior::test_write_with_version_conditions                 ... ok
   test behavior::test_write_if_not_changed                          ... ok
   test behavior::test_write_with_user_metadata                      ... ok
   test behavior::test_list_dir_with_recursive_no_trailing_slash     ... ok
   test behavior::test_writer_write                                  ... ok
   test behavior::test_rename_file                                   ... ok
   test behavior::test_writer_write_with_concurrent                  ... ok
   test behavior::test_writer_sink                                   ... ok
   test behavior::test_writer_sink_with_concurrent                   ... ok
   test behavior::test_rename_overwrite                              ... ok
   test behavior::test_stat_not_exist                                ... ok
   test behavior::test_writer_futures_copy                           ... ok
   test behavior::test_writer_futures_copy_with_concurrent           ... ok
   test behavior::test_writer_return_metadata                        ... ok
   test behavior::test_writer_copy_from_interleaved                  ... ok
   test behavior::test_write_only                                    ... ok
   test behavior::test_writer_write_with_if_not_exists               ... ok
   test behavior::test_writer_write_with_if_none_match               ... ok
   test behavior::test_writer_write_with_if_match                    ... ok
   test behavior::test_writer_write_with_version_conditions          ... ok
   test behavior::test_writer_abort                                  ... ok
   test behavior::test_writer_abort_with_concurrent                  ... ok
   test behavior::test_stat_file                                     ... ok
   test behavior::test_write_returns_metadata                        ... ok
   test behavior::test_write_with_special_chars                      ... ok
   test behavior::test_writer_write_non_contiguous_data              ... ok
   test behavior::test_writer_write_with_overwrite                   ... ok
   
   test result: ok. 128 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 93.81s
   
        Running unittests src/lib.rs (target/debug/deps/opendal_core-03b7e5357f19372b)
   
   running 0 tests
   
   test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 236 filtered out; finished in 0.00s
   
   ```
   
   # AI Usage Statement
   
   - Harness: OpenCode
   - Model: Qwen3.8-Flash-Next
   - Effort: `xhigh`
   - Role: Researched the Drive API documentation, rclone's drive backend, drafted the implementation and docs. I reviewed the changes against #4591 proposals and ran the behavior tests above against a real shared drive.


-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(services/gdrive): support shared drives [opendal]

Posted by "AlphaJack (via GitHub) via commits" <co...@opendal.apache.org>.
AlphaJack commented on PR #8410:
URL: https://github.com/apache/opendal/pull/8410#issuecomment-6557974834

   Thanks @Xuanwo!


-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(services/gdrive): support shared drives [opendal]

Posted by "Xuanwo (via GitHub) via commits" <co...@opendal.apache.org>.
Xuanwo merged PR #8410:
URL: https://github.com/apache/opendal/pull/8410


-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org