From 1d1603e0ad843b7f9b1f02823e0b7de2ce8d5712 Mon Sep 17 00:00:00 2001 From: Abhishek Pandey Date: Fri, 16 Jun 2023 02:14:36 -0700 Subject: [PATCH] Add prev delta --- src/internal/m365/onedrive/collections.go | 4 +++- src/internal/m365/onedrive/collections_test.go | 1 + src/internal/m365/onedrive/url_cache.go | 6 ++++-- src/internal/m365/onedrive/url_cache_test.go | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/internal/m365/onedrive/collections.go b/src/internal/m365/onedrive/collections.go index 9a4d42db0..917dd1ecc 100644 --- a/src/internal/m365/onedrive/collections.go +++ b/src/internal/m365/onedrive/collections.go @@ -394,6 +394,7 @@ func (c *Collections) Get( err = c.addURLCacheToDriveCollections( ictx, driveID, + prevDelta, errs) if err != nil { return nil, false, err @@ -465,11 +466,12 @@ func (c *Collections) Get( // a drive. func (c *Collections) addURLCacheToDriveCollections( ctx context.Context, - driveID string, + driveID, prevDelta string, errs *fault.Bus, ) error { uc, err := newURLCache( driveID, + prevDelta, urlCacheRefreshInterval, c.handler.NewItemPager(driveID, "", api.DriveItemSelectDefault()), errs) diff --git a/src/internal/m365/onedrive/collections_test.go b/src/internal/m365/onedrive/collections_test.go index f6350937a..5e72f7328 100644 --- a/src/internal/m365/onedrive/collections_test.go +++ b/src/internal/m365/onedrive/collections_test.go @@ -2739,6 +2739,7 @@ func (suite *OneDriveCollectionsUnitSuite) TestURLCacheIntegration() { err := c.addURLCacheToDriveCollections( ctx, driveID, + "", fault.New(true)) require.NoError(t, err, clues.ToCore(err)) diff --git a/src/internal/m365/onedrive/url_cache.go b/src/internal/m365/onedrive/url_cache.go index babd92c97..bfa4b16f8 100644 --- a/src/internal/m365/onedrive/url_cache.go +++ b/src/internal/m365/onedrive/url_cache.go @@ -32,6 +32,7 @@ var _ getItemPropertyer = &urlCache{} // urlCache caches download URLs for drive items type urlCache struct { driveID string + prevDelta string idToProps map[string]itemProps lastRefreshTime time.Time refreshInterval time.Duration @@ -48,7 +49,7 @@ type urlCache struct { // newURLache creates a new URL cache for the specified drive ID func newURLCache( - driveID string, + driveID, prevDelta string, refreshInterval time.Duration, itemPager api.DriveItemEnumerator, errs *fault.Bus, @@ -65,6 +66,7 @@ func newURLCache( idToProps: make(map[string]itemProps), lastRefreshTime: time.Time{}, driveID: driveID, + prevDelta: prevDelta, refreshInterval: refreshInterval, itemPager: itemPager, errs: errs, @@ -182,7 +184,7 @@ func (uc *urlCache) deltaQuery( "", uc.updateCache, map[string]string{}, - "", + uc.prevDelta, uc.errs) if err != nil { return clues.Wrap(err, "delta query") diff --git a/src/internal/m365/onedrive/url_cache_test.go b/src/internal/m365/onedrive/url_cache_test.go index 1632c165a..77aea7aa9 100644 --- a/src/internal/m365/onedrive/url_cache_test.go +++ b/src/internal/m365/onedrive/url_cache_test.go @@ -112,6 +112,7 @@ func (suite *URLCacheIntegrationSuite) TestURLCacheBasic() { // Create a new URL cache with a long TTL cache, err := newURLCache( suite.driveID, + "", 1*time.Hour, driveItemPager, fault.New(true))