For Google Drive apps that need to keep track of changes to items in Drive, the Changes collection provides an efficient way to detect changes. The collection works by providing the current state of each item, if and only if the item has changed since a given point in time.
Google Drive keeps a change log for each user and Team Drive. Each has their own record of changes to items that are of interest to them.
To track changes for all items visible to a user, both the user change log and the change logs for all Team Drives the user is a member of need to be replayed.
A change entry represents the state of the file or Team Drive at a given point in time. A change does not provide a delta between revisions. Applications that need to know which properties have changed should persist the previously known state of the item and compare.
Since changes represent the current state of an item, individual change entries may be invalidated and replaced with a newer change entry for the corresponding item.
Change entries for items no longer available to a user are marked as
in the change entry. Only the ID of the item is available in the change entry.
Tracking Team Drives
Each Team Drive has it's own change log. Even though a user may be a member of a Team Drive, certain changes are only reflected in the Team Drive change log and never in the user’s change log. If a file belongs to a Team Drive, even if the file still appeared on the user’s change log at some point in the past, replaying the user’s change log alone won't correctly update the file's status. Instead you must replay the Team Drive’s change log to capture all changes.
Changes that appear on a user change log
A user’s change log includes changes to Team Drives they're a member of as well as changes to files in the default corpus.
These Team Drive changes appear on the user’s change log:
- The user becomes a member of a Team Drive.
- The user is no longer a member of a Team Drive.
- There is a directly relevant change to a Team Drive in which the user is a
member, for example:
- The user’s access level on that Team Drive changed.
- The Team Drive is renamed.
When a user becomes a member of a Team Drive, a single change event for the Team Drive appears in the user's change log. This implies access to all items in the Team Drive. The user does not receive changes for items contained inside the Team Drive when they become a member.
Members of a Team Drive may see change events for items in a Team Drive based on their usage. However, applications should not rely on these events when the user is a member of the Team Drive. Instead, use the Team Drive's change log to track changes.
If a non-member is granted file access to individual items in a Team Drive, changes to those items are tracked in the user's change log. This is the same as non-Team Drive items that are shared directly with users.
Changes that appear on a Team Drive change log
If a user is a member of a Team Drive, they can access that Team Drive's change log which contains:
- Any changes to the Team Drive itself, such as addition or removal of a member
- Direct changes to the items contained in the Team Drive.
Syncing permissions and capabilities
Permission changes to Team Drives or items inside a Team Drive are only reflected on the item itself. While all direct or indirect children of that item will inherit this change there will not be a separate entry in the change log for each of those items. Clients must either propagate the new capabilities or refetch each item if a parent has changed in order to fully reconstruct the changes.