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

iclouddrive: fix panic and files potentially downloaded twice

Clément Wehrung9d55b2411f4c
diff --git a/backend/iclouddrive/api/drive.go b/backend/iclouddrive/api/drive.go
index 3bee22e24..a0856b262 100644
--- a/backend/iclouddrive/api/drive.go
+++ b/backend/iclouddrive/api/drive.go
@@ -252,18 +252,14 @@ func (d *DriveService) DownloadFile(ctx context.Context, url string, opt []fs.Op
}
resp, err := d.icloud.srv.Call(ctx, opts)
- if err != nil {
- // icloud has some weird http codes
- if resp.StatusCode == 330 {
- loc, err := resp.Location()
- if err == nil {
- return d.DownloadFile(ctx, loc.String(), opt)
- }
+ // icloud has some weird http codes
+ if err != nil && resp != nil && resp.StatusCode == 330 {
+ loc, err := resp.Location()
+ if err == nil {
+ return d.DownloadFile(ctx, loc.String(), opt)
}
-
- return resp, err
}
- return d.icloud.srv.Call(ctx, opts)
+ return resp, err
}
// MoveItemToTrashByItemID moves an item to the trash based on the item ID.