Check for new and older content URLs (#3263)
Some requests appear to be returning an older version of the content URL key. This was causing corso backup failures. This commit expands the logic to check for both the new and old keys for the URL. --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change - [ ] 🌻 Feature - [x] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) * closes #3262 #### Test Plan - [x] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
6e3403f717
commit
619bcd6eb8
@ -20,11 +20,11 @@ import (
|
||||
"github.com/alcionai/corso/src/pkg/logger"
|
||||
)
|
||||
|
||||
const (
|
||||
// downloadUrlKey is used to find the download URL in a
|
||||
// DriveItem response
|
||||
downloadURLKey = "@microsoft.graph.downloadUrl"
|
||||
)
|
||||
// downloadUrlKeys is used to find the download URL in a DriveItem response.
|
||||
var downloadURLKeys = []string{
|
||||
"@microsoft.graph.downloadUrl",
|
||||
"@content.downloadUrl",
|
||||
}
|
||||
|
||||
// sharePointItemReader will return a io.ReadCloser for the specified item
|
||||
// It crafts this by querying M365 for a download URL for the item
|
||||
@ -135,12 +135,21 @@ func downloadItem(
|
||||
client graph.Requester,
|
||||
item models.DriveItemable,
|
||||
) (*http.Response, error) {
|
||||
url, ok := item.GetAdditionalData()[downloadURLKey].(*string)
|
||||
if !ok {
|
||||
var url string
|
||||
|
||||
for _, key := range downloadURLKeys {
|
||||
tmp, ok := item.GetAdditionalData()[key].(*string)
|
||||
if ok {
|
||||
url = ptr.Val(tmp)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if len(url) == 0 {
|
||||
return nil, clues.New("extracting file url").With("item_id", ptr.Val(item.GetId()))
|
||||
}
|
||||
|
||||
resp, err := client.Request(ctx, http.MethodGet, ptr.Val(url), nil, nil)
|
||||
resp, err := client.Request(ctx, http.MethodGet, url, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user