From 1ee40fecbe30237f2d54daa7aa548582073fbcaf Mon Sep 17 00:00:00 2001 From: Abin Simon Date: Wed, 31 Jan 2024 22:43:05 +0530 Subject: [PATCH] Use /content instead of download link from delta --- .../m365/collection/drive/collection.go | 4 ++-- src/internal/m365/collection/drive/item.go | 19 ++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/internal/m365/collection/drive/collection.go b/src/internal/m365/collection/drive/collection.go index aa196281a..6a3a3edd6 100644 --- a/src/internal/m365/collection/drive/collection.go +++ b/src/internal/m365/collection/drive/collection.go @@ -366,7 +366,7 @@ func downloadContent( itemID := ptr.Val(item.GetId()) ctx = clues.Add(ctx, "item_id", itemID) - content, err := downloadItem(ctx, iaag, item) + content, err := downloadItem(ctx, iaag, driveID, item) if err == nil { return content, nil } else if !graph.IsErrUnauthorizedOrBadToken(err) { @@ -395,7 +395,7 @@ func downloadContent( cdi := custom.ToCustomDriveItem(di) - content, err = downloadItem(ctx, iaag, cdi) + content, err = downloadItem(ctx, iaag, driveID, cdi) if err != nil { return nil, clues.Wrap(err, "content download retry") } diff --git a/src/internal/m365/collection/drive/item.go b/src/internal/m365/collection/drive/item.go index 02ac6010a..3c771e8e7 100644 --- a/src/internal/m365/collection/drive/item.go +++ b/src/internal/m365/collection/drive/item.go @@ -11,7 +11,6 @@ import ( "github.com/alcionai/corso/src/internal/common/ptr" "github.com/alcionai/corso/src/internal/common/readers" - "github.com/alcionai/corso/src/internal/common/str" "github.com/alcionai/corso/src/internal/m365/collection/drive/metadata" "github.com/alcionai/corso/src/pkg/count" "github.com/alcionai/corso/src/pkg/logger" @@ -34,6 +33,7 @@ var downloadURLKeys = []string{ func downloadItem( ctx context.Context, ag api.Getter, + driveID string, item *custom.DriveItem, ) (io.ReadCloser, error) { if item == nil { @@ -47,17 +47,14 @@ func downloadItem( ) if isFile { - var ( - url string - ad = item.GetAdditionalData() - ) + url := "https://graph.microsoft.com/v1.0/" + driveID + "/items/" + ptr.Val(item.GetId()) + "/content" - for _, key := range downloadURLKeys { - if v, err := str.AnyValueToString(key, ad); err == nil { - url = v - break - } - } + // for _, key := range downloadURLKeys { + // if v, err := str.AnyValueToString(key, ad); err == nil { + // url = v + // break + // } + // } rc, err = downloadFile(ctx, ag, url) if err != nil {