From 671fd5150d4fec46bbc841f99b46b71daa15c0a4 Mon Sep 17 00:00:00 2001 From: Abhishek Pandey Date: Wed, 31 May 2023 04:08:30 -0700 Subject: [PATCH] Cherry pick cache integration changes with dummy url cache --- src/internal/m365/onedrive/collection.go | 2 +- src/internal/m365/onedrive/collection_test.go | 2 ++ src/internal/m365/onedrive/collections.go | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/internal/m365/onedrive/collection.go b/src/internal/m365/onedrive/collection.go index 1da2e4673..59b03bf1a 100644 --- a/src/internal/m365/onedrive/collection.go +++ b/src/internal/m365/onedrive/collection.go @@ -323,7 +323,7 @@ type itemAndAPIGetter interface { // downloadContent attempts to fetch the item content. If the content url // is expired (ie, returns a 401), it re-fetches the item to get a new download // url and tries again. -func downloadContent( +func (oc *Collection) downloadContent( ctx context.Context, iaag itemAndAPIGetter, uc getItemPropertyer, diff --git a/src/internal/m365/onedrive/collection_test.go b/src/internal/m365/onedrive/collection_test.go index 4b8cc53b6..0147bba60 100644 --- a/src/internal/m365/onedrive/collection_test.go +++ b/src/internal/m365/onedrive/collection_test.go @@ -207,6 +207,8 @@ func (suite *CollectionUnitTestSuite) TestCollection() { CollectionScopeFolder, true, nil) + true, + nil) require.NoError(t, err, clues.ToCore(err)) require.NotNil(t, coll) assert.Equal(t, folderPath, coll.FullPath()) diff --git a/src/internal/m365/onedrive/collections.go b/src/internal/m365/onedrive/collections.go index 2f270ad0a..9a4d42db0 100644 --- a/src/internal/m365/onedrive/collections.go +++ b/src/internal/m365/onedrive/collections.go @@ -63,6 +63,9 @@ type Collections struct { NumItems int NumFiles int NumContainers int + + // drive ID -> url cache instance + driveURLCache map[string]*urlCache } func NewCollections( @@ -79,6 +82,7 @@ func NewCollections( CollectionMap: map[string]map[string]*Collection{}, statusUpdater: statusUpdater, ctrl: ctrlOpts, + driveURLCache: map[string]*urlCache{}, } }