mirror of
https://github.com/rclone/rclone.git
synced 2024-11-08 01:25:14 +01:00
onedrive: add missing drive on config - fixes #4068
Before this change we queries /me/drives for a list of the users drives and asked the user to choose. Sometimes this does not return the users main drive for reasons unknown. After this change we query /me/drives first then /me/drive and add that to the list of drives if it wasn't already there.
This commit is contained in:
parent
243a868a5b
commit
d9c8c47e02
@ -184,6 +184,28 @@ func init() {
|
||||
log.Fatalf("Failed to query available drives: %v", err)
|
||||
}
|
||||
|
||||
// Also call /me/drive as sometimes /me/drives doesn't return it #4068
|
||||
if opts.Path == "/me/drives" {
|
||||
opts.Path = "/me/drive"
|
||||
meDrive := driveResource{}
|
||||
_, err := srv.CallJSON(ctx, &opts, nil, &meDrive)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to query available drives: %v", err)
|
||||
}
|
||||
found := false
|
||||
for _, drive := range drives.Drives {
|
||||
if drive.DriveID == meDrive.DriveID {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
// add the me drive if not found already
|
||||
if !found {
|
||||
fs.Debugf(nil, "Adding %v to drives list from /me/drive", meDrive)
|
||||
drives.Drives = append(drives.Drives, meDrive)
|
||||
}
|
||||
}
|
||||
|
||||
if len(drives.Drives) == 0 {
|
||||
log.Fatalf("No drives found")
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user