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 single Drive Document as FS root

Fabian Möller29286cc8b389
diff --git a/backend/drive/drive.go b/backend/drive/drive.go
index 8734c98c1..026c81c22 100644
--- a/backend/drive/drive.go
+++ b/backend/drive/drive.go
@@ -507,13 +507,19 @@ func NewFs(name, path string) (fs.Fs, error) {
// No root so return old f
return f, nil
}
- _, err := newF.newObjectWithInfo(remote, nil)
+ entries, err := newF.List("")
if err != nil {
- // File doesn't exist so return old f
+ // unable to list folder so return old f
return f, nil
}
- // return an error with an fs which points to the parent
- return &newF, fs.ErrorIsFile
+ for _, e := range entries {
+ if _, isObject := e.(fs.Object); isObject && e.Remote() == remote {
+ // return an error with an fs which points to the parent
+ return &newF, fs.ErrorIsFile
+ }
+ }
+ // File doesn't exist so return old f
+ return f, nil
}
// fmt.Printf("Root id %s", f.dirCache.RootID())
return f, nil