Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

drive: fix listing of the root directory with drive.files scope

Nick Craig-Wood1e423d21e18d
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)