diff --git a/backend/drive/drive.go b/backend/drive/drive.go index a24de71a2..252ab5081 100755 --- a/backend/drive/drive.go +++ b/backend/drive/drive.go @@ -349,9 +349,12 @@ date is used.`, Help: "Size of listing chunk 100-1000. 0 to disable.", Advanced: true, }, { - Name: "impersonate", - Default: "", - Help: "Impersonate this user when using a service account.", + Name: "impersonate", + Default: "", + Help: `Impersonate this user when using a service account. + +Note that if this is used then "root_folder_id" will be ignored. +`, Advanced: true, }, { Name: "alternate_export", @@ -1118,9 +1121,20 @@ func NewFs(name, path string, m configmap.Mapper) (fs.Fs, error) { } } + // If impersonating warn about root_folder_id if set and unset it + // + // This is because rclone v1.51 and v1.52 cached root_folder_id when + // using impersonate which they shouldn't have done. It is possible + // someone is using impersonate and root_folder_id in which case this + // breaks their workflow. There isn't an easy way around that. + if opt.RootFolderID != "" && opt.Impersonate != "" { + fs.Logf(f, "Ignoring cached root_folder_id when using --drive-impersonate") + opt.RootFolderID = "" + } + // set root folder for a team drive or query the user root folder if opt.RootFolderID != "" { - // override root folder if set or cached in the config + // override root folder if set or cached in the config and not impersonating f.rootFolderID = opt.RootFolderID } else if f.isTeamDrive { f.rootFolderID = f.opt.TeamDriveID @@ -1137,7 +1151,10 @@ func NewFs(name, path string, m configmap.Mapper) (fs.Fs, error) { } } f.rootFolderID = rootID - m.Set("root_folder_id", rootID) + // Don't cache the root folder ID if impersonating + if opt.Impersonate == "" { + m.Set("root_folder_id", rootID) + } } f.dirCache = dircache.New(root, f.rootFolderID, f)