From 9662554f53fc68fdbbf0eabed8c7733effdb35b4 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 ffdb874c3..4c3048f8b 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)