forked from TrueCloudLab/rclone
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
db930850cc
commit
9662554f53
1 changed files with 7 additions and 1 deletions
|
@ -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…
Add table
Reference in a new issue