Skip to content

Update drive use v3 API #320

Closed
Closed

Description

@ncw

v3 is now available in the go interface package - update rclone to use it.

  • do conversion - see WIP: Update drive use v3 API #2007
  • fixup places in the VFS layer which might be confused by size < 0
  • fixup sync routines to treat a size < 0 as size unknown
  • investigate whether we can avoid reading the "root" id which is doing an extra transaction on startup

Activity

  1. gustavorochakv commented on Jan 26, 2016

    @gustavorochakv

    I should note that the doc for the new File.update method no longer lists the newRevision optional query parameter, and there's also no mention about whether it adds a new revision for existing files like the previous API.

    I haven't tested the new API yet, but if it doesn't add a revision this would lead to a behaviour change.

  2. ncw commented on Jan 28, 2016

    @ncw
    MemberAuthor

    @gustavorochakv thanks for the heads up.

  3. added this to the Soon milestone on Jun 17, 2016
  4. rwaldspur commented on Jun 29, 2017

    @rwaldspur

    Nick, is the Google Drive API in the betas now at v3? I am using the beta successfully with Team Drives, and it's unclear to me from the google docs if Team Drives formally depend on v3.

  5. ncw commented on Jun 30, 2017

    @ncw
    MemberAuthor

    No it is still on v2. Google have updated the v2 API to work with Team Drives.

  6. Cubox commented on Aug 1, 2017

    @Cubox
    Contributor

    I am willing to try and see what needs to be done in order to convert to v3. The changed APIs and parameters are listed here: https://developers.google.com/drive/v3/web/migration

  7. modified the milestones: Soon, v1.40 on Jan 29, 2018
  8. B4dM4n commented on Jan 29, 2018

    @B4dM4n
    Collaborator

    Since the change to API v3 there is a API call to the About service to get the exportFormats in drive.go#L533.

    I was thinking about ways to get rid of this call, as it slows down NewFS.
    One method i could find was B4dM4n/rclone@58fa712:

    diff --git a/backend/drive/drive.go b/backend/drive/drive.go
    index f81e98f9..de1642b1 100644
    --- a/backend/drive/drive.go
    +++ b/backend/drive/drive.go
    @@ -530,15 +530,19 @@ func NewFs(name, path string) (fs.Fs, error) {
     
            f.dirCache = dircache.New(root, f.rootFolderID, f)
     
    -       var about *drive.About
    -       err = f.pacer.Call(func() (bool, error) {
    -               about, err = f.svc.About.Get().Fields("exportFormats").Do()
    -               return shouldRetry(err)
    -       })
    -       if err != nil {
    -               return nil, errors.Wrap(err, "couldn't get Drive exportFormats")
    +       if !*driveSkipGdocs {
    +               var about *drive.About
    +               err = f.pacer.Call(func() (bool, error) {
    +                       about, err = f.svc.About.Get().Fields("exportFormats").Do()
    +                       return shouldRetry(err)
    +               })
    +               if err != nil {
    +                       return nil, errors.Wrap(err, "couldn't get Drive exportFormats")
    +               }
    +               f.exportFormats = about.ExportFormats
    +       } else {
    +               fs.Debugf(f, "Skipping google documents")
            }
    -       f.exportFormats = about.ExportFormats
     
            // Parse extensions
            err = f.parseExtensions(*driveExtensions)

    This change would make the call depended on the driveSkipGdocs flag, which is false by default, so most users won't benefit from it.

    To completely get rid of it we would have to put the exportFormats in the source.
    It could be half automated using a go generate script or a make rule, but this would need a configured drive remote to work.

    Would removing one call during NewFS be worth the effort?

  9. ncw commented on Jan 30, 2018

    @ncw
    MemberAuthor

    @gustavorochakv wrote:

    I should note that the doc for the new File.update method no longer lists the newRevision optional query parameter, and there's also no mention about whether it adds a new revision for existing files like the previous API.

    It does create new revisions - I checked, so this behaviour hasn't changed.

  10. ncw commented on Jan 30, 2018

    @ncw
    MemberAuthor

    @B4dM4n wrote:

    Would removing one call during NewFS be worth the effort?

    I think so...

    This change would make the call depended on the driveSkipGdocs flag, which is false by default, so most users won't benefit from it.

    I was thinking about the same thing, but my idea was to do the About call in a function wrapped in a sync.Once, so just call this setupExports (or whatever) function just before exports are needed. This then gets rid of the cost for all users which don't have any Gdocs in their remote (or in the part of it that is being listed).

    To completely get rid of it we would have to put the exportFormats in the source.
    It could be half automated using a go generate script or a make rule, but this would need a configured drive remote to work.

    I think that is probably a step too far as we'd then need to release a new rclone if Google change the formats

    We could cache it on disk. Rclone now has a place to cache things... We'd need to update it when it got old so that is still quite a lot of work.

    I think the just-in-time API call approach is probably the best - what do you think? Would that work out?

  11. ncw commented on Mar 16, 2018

    @ncw
    MemberAuthor

    I think this is all done now - thanks @B4dM4n for all your help :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions