mirror of
https://github.com/rclone/rclone.git
synced 2024-12-23 15:38:57 +01:00
drive: stop using root_folder_id as a cache #4419
Previous to this change rclone cached the looked up root_folder_id in the root_folder_id config variable. This has caused a lot of confusion and a few attempts at workarounds and ultimately was a mistake. This reverts rclone attempting to cache anything in root_folder_id and returns that variable to be entirely user modified. It gives a little hint in the debug that rclone could be sped up slightly by setting it, but it is up to the user to think about whether that would be OK or not. Google drive root '': root_folder_id = "XXX" - save this in the config to speed up startup It does not change root_folder_id itself, leaving this to the user. See: https://forum.rclone.org/t/rclone-gdrive-no-longer-returning-anything/17215
This commit is contained in:
parent
0c620ad076
commit
f50ab981f7
@ -224,9 +224,6 @@ Leave blank normally.
|
||||
|
||||
Fill in to access "Computers" folders (see docs), or for rclone to use
|
||||
a non root folder as its starting point.
|
||||
|
||||
Note that if this is blank, the first time rclone runs it will fill it
|
||||
in with the ID of the root folder.
|
||||
`,
|
||||
}, {
|
||||
Name: "service_account_file",
|
||||
@ -352,10 +349,7 @@ date is used.`,
|
||||
}, {
|
||||
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.
|
||||
`,
|
||||
Help: `Impersonate this user when using a service account.`,
|
||||
Advanced: true,
|
||||
}, {
|
||||
Name: "alternate_export",
|
||||
@ -1112,25 +1106,15 @@ func NewFs(name, path string, m configmap.Mapper) (fs.Fs, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 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 f.opt.RootFolderID != "" && f.opt.RootFolderID != "appDataFolder" && f.opt.Impersonate != "" {
|
||||
fs.Logf(f, "Ignoring cached root_folder_id when using --drive-impersonate")
|
||||
f.opt.RootFolderID = ""
|
||||
}
|
||||
|
||||
// set root folder for a team drive or query the user root folder
|
||||
// Set the root folder ID
|
||||
if f.opt.RootFolderID != "" {
|
||||
// override root folder if set or cached in the config and not impersonating
|
||||
// use root_folder ID if set
|
||||
f.rootFolderID = f.opt.RootFolderID
|
||||
} else if f.isTeamDrive {
|
||||
// otherwise use team_drive if set
|
||||
f.rootFolderID = f.opt.TeamDriveID
|
||||
} else {
|
||||
// Look up the root ID and cache it in the config
|
||||
// otherwise look up the actual root ID
|
||||
rootID, err := f.getRootID()
|
||||
if err != nil {
|
||||
if gerr, ok := errors.Cause(err).(*googleapi.Error); ok && gerr.Code == 404 {
|
||||
@ -1142,10 +1126,7 @@ func NewFs(name, path string, m configmap.Mapper) (fs.Fs, error) {
|
||||
}
|
||||
}
|
||||
f.rootFolderID = rootID
|
||||
// Don't cache the root folder ID if impersonating
|
||||
if f.opt.Impersonate == "" {
|
||||
m.Set("root_folder_id", rootID)
|
||||
}
|
||||
fs.Debugf(f, "root_folder_id = %q - save this in the config to speed up startup", rootID)
|
||||
}
|
||||
|
||||
f.dirCache = dircache.New(f.root, f.rootFolderID, f)
|
||||
|
Loading…
Reference in New Issue
Block a user