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

onedrive: More accurately check if root is found - fixes #3164

Cnlye4c2468244f6
diff --git a/backend/onedrive/onedrive.go b/backend/onedrive/onedrive.go
index 48786794d..6b8c9e053 100644
--- a/backend/onedrive/onedrive.go
+++ b/backend/onedrive/onedrive.go
@@ -385,9 +385,19 @@ func (f *Fs) readMetaDataForPath(path string) (info *api.Item, resp *http.Respon
var dirCacheFoundRoot bool
var rootNormalizedID string
if f.dirCache != nil {
- var ok bool
- if rootNormalizedID, ok = f.dirCache.Get(""); ok {
- dirCacheFoundRoot = true
+ var dirCacheRootIDExists bool
+ rootNormalizedID, dirCacheRootIDExists = f.dirCache.Get("")
+ if f.root == "" {
+ // if f.root == "", it means f.root is the absolute root of the drive
+ // and its ID should have been found in NewFs
+ dirCacheFoundRoot = dirCacheRootIDExists
+ } else if _, err := f.dirCache.RootParentID(); err == nil {
+ // if root is in a folder, it must have a parent folder, and
+ // if dirCache has found root in NewFs, the parent folder's ID
+ // should be present.
+ // This RootParentID() check is a fix for #3164 which describes
+ // a possible case where the root is not found.
+ dirCacheFoundRoot = dirCacheRootIDExists
}
}