googlearchive/PyDrive

Shared Drive Metadata Fetch Unsupported

Opened this issue · 2 comments

7mt commented

The Handling Special Metadata section of the docs highlights the following use case of the FetchMetadata() function:

file1 = drive.CreateFile({'id': '<some file ID here>'})

# Fetches all basic metadata fields, including file size, last modified etc.
file1.FetchMetadata()

However, this does not work if file1 is a shared drive. When file1 is a shared drive,

shared_drive = client.CreateFile({'teamDriveId': shared_drive_id})
print(shared_drive['id'])

returns a GoogleDriveFile object with blank metadata (i.e. no 'id' field). Therefore, when
file_id = self.metadata.get('id') or self.get('id')
is executed in the FetchMetadata function, file_id is None and FileNotUploadedError() is raised.

This error propagates into other functions that call FetchMetadata (e.g. GetPermissions()).

@7mt could you check if it is fixed in the PyDrive2 (a maintainer fork)?

7mt commented

Hi @shcheklein, just tested in PyDrive2 and I'm getting the same error.