-
Notifications
You must be signed in to change notification settings - Fork 264
Issue #269 - supporting shortcuts #272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for resolving Google Drive shortcuts (issue #269) and removes the supportsAllDrives parameter from get_media and export_media calls. The implementation introduces two new helper functions that dereference shortcuts to their target items before performing operations.
- Adds
resolve_drive_item()andresolve_folder_id()functions to handle shortcut resolution - Updates multiple Drive operations to resolve shortcuts before processing
- Removes
supportsAllDrivesparameter from media download operations
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| gdrive/drive_tools.py | Integrates shortcut resolution into file operations (get_drive_file_content, list_drive_items, create_drive_file, get_drive_file_permissions, check_drive_file_public_access, update_drive_file) |
| gdrive/drive_helpers.py | Adds new helper functions for resolving shortcuts with depth limiting and type validation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| resolved_file_id, _ = await resolve_drive_item(service, file_id) | ||
| file_id = resolved_file_id | ||
|
|
Copilot
AI
Nov 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace on line 463. Remove the extra spaces after the statement for code cleanliness.
| if mime_type != SHORTCUT_MIME_TYPE: | ||
| return current_id, metadata | ||
|
|
||
| shortcut_details = metadata.get("shortcutDetails") or {} |
Copilot
AI
Nov 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using or {} after .get() can mask None values in the dictionary. If shortcutDetails exists but is explicitly None, this will incorrectly return an empty dict. Use metadata.get('shortcutDetails', {}) instead to only provide a default when the key is missing.
| shortcut_details = metadata.get("shortcutDetails") or {} | |
| shortcut_details = metadata.get("shortcutDetails", {}) |
| mime_type = metadata.get("mimeType") | ||
| if mime_type != FOLDER_MIME_TYPE: | ||
| raise Exception( | ||
| f"Resolved ID '{resolved_id}' (from '{folder_id}') is not a folder; mimeType={mime_type}." | ||
| ) |
Copilot
AI
Nov 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mimeType field is already included in BASE_SHORTCUT_FIELDS, so the extra_fields='mimeType' parameter on line 173 is redundant. Remove this parameter to avoid unnecessary duplication.
#269 This patch also includes a removal of the supportAllDrives parameter for get_media/export_media calls as that was raising errors and it's now further up in dereferencing the file.