Skip to content

Conversation

@silarsis
Copy link

@silarsis silarsis commented Nov 11, 2025

#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.

Copy link
Contributor

Copilot AI left a 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() and resolve_folder_id() functions to handle shortcut resolution
  • Updates multiple Drive operations to resolve shortcuts before processing
  • Removes supportsAllDrives parameter 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

Copy link

Copilot AI Nov 16, 2025

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.

Suggested change

Copilot uses AI. Check for mistakes.
if mime_type != SHORTCUT_MIME_TYPE:
return current_id, metadata

shortcut_details = metadata.get("shortcutDetails") or {}
Copy link

Copilot AI Nov 16, 2025

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.

Suggested change
shortcut_details = metadata.get("shortcutDetails") or {}
shortcut_details = metadata.get("shortcutDetails", {})

Copilot uses AI. Check for mistakes.
Comment on lines +176 to +180
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}."
)
Copy link

Copilot AI Nov 16, 2025

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.

Copilot uses AI. Check for mistakes.
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.

4 participants