mirror of
https://github.com/rclone/rclone.git
synced 2025-01-10 16:28:30 +01:00
drive: fix listing of the root directory with drive.files scope
We attempt to find the ID of the root folder by doing a GET on the folder ID "root". With scope "drive.files" this fails with a 404 message. After this change if we get the 404 message, we just carry on using "root" as the root folder ID and we cache that for future lookups. This means that changenotify messages will not work correctly in the root folder but otherwise has minor consequences. See: https://forum.rclone.org/t/fresh-raspberry-pi-build-google-drive-404-error-failed-to-ls-googleapi-error-404-file-not-found/12791
This commit is contained in:
parent
53d55ae760
commit
1e423d21e1
@ -1030,7 +1030,13 @@ func NewFs(name, path string, m configmap.Mapper) (fs.Fs, error) {
|
||||
// Look up the root ID and cache it in the config
|
||||
rootID, err := f.getRootID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if gerr, ok := errors.Cause(err).(*googleapi.Error); ok && gerr.Code == 404 {
|
||||
// 404 means that this scope does not have permission to get the
|
||||
// root so just use "root"
|
||||
rootID = "root"
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
f.rootFolderID = rootID
|
||||
m.Set("root_folder_id", rootID)
|
||||
|
Loading…
Reference in New Issue
Block a user