diff --git a/src/internal/connector/data_collections.go b/src/internal/connector/data_collections.go index 36d05b731..81dcc580b 100644 --- a/src/internal/connector/data_collections.go +++ b/src/internal/connector/data_collections.go @@ -109,16 +109,16 @@ func verifyBackupInputs(sels selectors.Selector, userPNs, siteIDs []string) erro func (gc *GraphConnector) createExchangeCollections( ctx context.Context, scope selectors.ExchangeScope, -) ([]*exchange.Collection, error) { +) ([]data.Collection, error) { var ( errs *multierror.Error users = scope.Get(selectors.ExchangeUser) - allCollections = make([]*exchange.Collection, 0) + allCollections = make([]data.Collection, 0) ) // Create collection of ExchangeDataCollection for _, user := range users { - collections := make(map[string]*exchange.Collection) + collections := make(map[string]data.Collection) qp := graph.QueryParams{ Category: scope.Category().PathType(), @@ -188,9 +188,7 @@ func (gc *GraphConnector) ExchangeDataCollection( return nil, support.WrapAndAppend(user[0], err, errs) } - for _, collection := range dcs { - collections = append(collections, collection) - } + collections = append(collections, dcs...) } return collections, errs diff --git a/src/internal/connector/data_collections_test.go b/src/internal/connector/data_collections_test.go index 391e7c6b7..5fe5befae 100644 --- a/src/internal/connector/data_collections_test.go +++ b/src/internal/connector/data_collections_test.go @@ -11,6 +11,7 @@ import ( "github.com/alcionai/corso/src/internal/connector/exchange" "github.com/alcionai/corso/src/internal/connector/sharepoint" "github.com/alcionai/corso/src/internal/connector/support" + "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/selectors" ) @@ -336,11 +337,11 @@ func (suite *ConnectorCreateExchangeCollectionIntegrationSuite) TestContactSeria tests := []struct { name string - getCollection func(t *testing.T) []*exchange.Collection + getCollection func(t *testing.T) []data.Collection }{ { name: "Default Contact Folder", - getCollection: func(t *testing.T) []*exchange.Collection { + getCollection: func(t *testing.T) []data.Collection { scope := selectors. NewExchangeBackup(). ContactFolders([]string{suite.user}, []string{exchange.DefaultContactFolder}, selectors.PrefixMatch())[0] @@ -389,12 +390,12 @@ func (suite *ConnectorCreateExchangeCollectionIntegrationSuite) TestEventsSerial tests := []struct { name, expected string - getCollection func(t *testing.T) []*exchange.Collection + getCollection func(t *testing.T) []data.Collection }{ { name: "Default Event Calendar", expected: exchange.DefaultCalendar, - getCollection: func(t *testing.T) []*exchange.Collection { + getCollection: func(t *testing.T) []data.Collection { sel := selectors.NewExchangeBackup() sel.Include(sel.EventCalendars([]string{suite.user}, []string{exchange.DefaultCalendar}, selectors.PrefixMatch())) collections, err := connector.createExchangeCollections(ctx, sel.Scopes()[0]) @@ -406,7 +407,7 @@ func (suite *ConnectorCreateExchangeCollectionIntegrationSuite) TestEventsSerial { name: "Birthday Calendar", expected: "Birthdays", - getCollection: func(t *testing.T) []*exchange.Collection { + getCollection: func(t *testing.T) []data.Collection { sel := selectors.NewExchangeBackup() sel.Include(sel.EventCalendars([]string{suite.user}, []string{"Birthdays"}, selectors.PrefixMatch())) collections, err := connector.createExchangeCollections(ctx, sel.Scopes()[0]) diff --git a/src/internal/connector/exchange/service_iterators.go b/src/internal/connector/exchange/service_iterators.go index 8609a305e..c21efcd52 100644 --- a/src/internal/connector/exchange/service_iterators.go +++ b/src/internal/connector/exchange/service_iterators.go @@ -14,6 +14,7 @@ import ( "github.com/alcionai/corso/src/internal/connector/graph" "github.com/alcionai/corso/src/internal/connector/support" + "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/pkg/path" "github.com/alcionai/corso/src/pkg/selectors" ) @@ -24,9 +25,9 @@ const nextLinkKey = "@odata.nextLink" // the value is not in the map returns an empty string. func getAdditionalDataString( key string, - data map[string]any, + addtlData map[string]any, ) string { - iface := data[key] + iface := addtlData[key] if iface == nil { return "" } @@ -47,45 +48,45 @@ func getAdditionalDataString( func FilterContainersAndFillCollections( ctx context.Context, qp graph.QueryParams, - collections map[string]*Collection, + collections map[string]data.Collection, statusUpdater support.StatusUpdater, resolver graph.ContainerResolver, scope selectors.ExchangeScope, ) error { var ( - collectionType = CategoryToOptionIdentifier(scope.Category().PathType()) errs error + collectionType = CategoryToOptionIdentifier(qp.Category) ) for _, c := range resolver.Items() { dirPath, ok := pathAndMatch(qp, c, scope) - if ok { - // Create only those that match - service, err := createService(qp.Credentials, qp.FailFast) - if err != nil { - errs = support.WrapAndAppend( - qp.ResourceOwner+" FilterContainerAndFillCollection", - err, - errs) - - if qp.FailFast { - return errs - } - } - - edc := NewCollection( - qp.ResourceOwner, - dirPath, - collectionType, - service, - statusUpdater, - ) - collections[*c.GetId()] = &edc + if !ok { + continue } - } - for directoryID, col := range collections { - fetchFunc, err := getFetchIDFunc(scope.Category().PathType()) + // Create only those that match + service, err := createService(qp.Credentials, qp.FailFast) + if err != nil { + errs = support.WrapAndAppend( + qp.ResourceOwner+" FilterContainerAndFillCollection", + err, + errs) + + if qp.FailFast { + return errs + } + } + + edc := NewCollection( + qp.ResourceOwner, + dirPath, + collectionType, + service, + statusUpdater, + ) + collections[*c.GetId()] = &edc + + fetchFunc, err := getFetchIDFunc(qp.Category) if err != nil { errs = support.WrapAndAppend( qp.ResourceOwner, @@ -99,7 +100,7 @@ func FilterContainersAndFillCollections( continue } - jobs, err := fetchFunc(ctx, col.service, qp.ResourceOwner, directoryID) + jobs, err := fetchFunc(ctx, edc.service, qp.ResourceOwner, *c.GetId()) if err != nil { errs = support.WrapAndAppend( qp.ResourceOwner, @@ -108,7 +109,7 @@ func FilterContainersAndFillCollections( ) } - col.jobs = append(col.jobs, jobs...) + edc.jobs = append(edc.jobs, jobs...) } return errs