From b8e868c05b6da24bb83d2954e437e38b4a3532e9 Mon Sep 17 00:00:00 2001 From: ashmrtn Date: Thu, 27 Apr 2023 09:25:12 -0700 Subject: [PATCH] Return SharePoint exclude information (#3242) Allows proper deletion of files and also fixes file moves. --- #### Does this PR need a docs update or release note? - [x] :white_check_mark: Yes, it's included - [ ] :clock1: Yes, but in a later PR - [ ] :no_entry: No #### Type of change - [ ] :sunflower: Feature - [x] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Supportability/Tests - [ ] :computer: CI/Deployment - [ ] :broom: Tech Debt/Cleanup #### Issue(s) * #3240 #### Test Plan - [x] :muscle: Manual - [ ] :zap: Unit test - [ ] :green_heart: E2E --- .../connector/sharepoint/data_collections.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/internal/connector/sharepoint/data_collections.go b/src/internal/connector/sharepoint/data_collections.go index 6f89c42ca..a759f27da 100644 --- a/src/internal/connector/sharepoint/data_collections.go +++ b/src/internal/connector/sharepoint/data_collections.go @@ -4,6 +4,7 @@ import ( "context" "github.com/alcionai/clues" + "golang.org/x/exp/maps" "github.com/alcionai/corso/src/internal/common/idname" "github.com/alcionai/corso/src/internal/connector/graph" @@ -53,6 +54,7 @@ func DataCollections( el = errs.Local() collections = []data.BackupCollection{} categories = map[path.CategoryType]struct{}{} + excluded = map[string]map[string]struct{}{} ) for _, scope := range b.Scopes() { @@ -84,7 +86,9 @@ func DataCollections( } case path.LibrariesCategory: - spcs, _, err = collectLibraries( + var excludes map[string]map[string]struct{} + + spcs, excludes, err = collectLibraries( ctx, itemClient, serv, @@ -100,6 +104,14 @@ func DataCollections( continue } + for prefix, excludes := range excludes { + if _, ok := excluded[prefix]; !ok { + excluded[prefix] = map[string]struct{}{} + } + + maps.Copy(excluded[prefix], excludes) + } + case path.PagesCategory: spcs, err = collectPages( ctx, @@ -138,7 +150,7 @@ func DataCollections( collections = append(collections, baseCols...) } - return collections, nil, el.Failure() + return collections, excluded, el.Failure() } func collectLists( @@ -216,8 +228,6 @@ func collectLibraries( ctrlOpts) ) - // TODO(ashmrtn): Pass previous backup metadata when SharePoint supports delta - // token-based incrementals. odcs, excludes, err := colls.Get(ctx, metadata, errs) if err != nil { return nil, nil, graph.Wrap(ctx, err, "getting library")