From 1e423d21e18d7c39e1bf8a2e7a762dda4c8edc4a Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 8 Nov 2019 10:29:45 +0000 Subject: [PATCH] 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 --- backend/drive/drive.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/drive/drive.go b/backend/drive/drive.go index 5e55ba3a3..cc8185395 100644 --- a/backend/drive/drive.go +++ b/backend/drive/drive.go @@ -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)