Wire up most of exclude list for OneDrive (#2379)

## Description

Push exclude list through the whole stack. It's not wired to kopia yet, but only one location (marked with a TODO) needs to be changed to have that happen.

## Does this PR need a docs update or release note?

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No 

## Type of change

- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Test
- [ ] 💻 CI/Deployment
- [x] 🧹 Tech Debt/Cleanup

## Issue(s)

* #2243

## Test Plan

- [ ] 💪 Manual
- [x]  Unit test
- [ ] 💚 E2E
This commit is contained in:
ashmrtn 2023-02-06 11:58:13 -08:00 committed by GitHub
parent 63ffd8004a
commit c4cc3b1a23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 11 deletions

View File

@ -359,7 +359,7 @@ func (c *Collections) Get(
} }
// TODO(ashmrtn): Track and return the set of items to exclude. // TODO(ashmrtn): Track and return the set of items to exclude.
return collections, nil, nil return collections, excludedItems, nil
} }
// UpdateCollections initializes and adds the provided drive items to Collections // UpdateCollections initializes and adds the provided drive items to Collections

View File

@ -1387,7 +1387,7 @@ func (suite *OneDriveCollectionsSuite) TestGet() {
c.itemPagerFunc = itemPagerFunc c.itemPagerFunc = itemPagerFunc
// TODO(ashmrtn): Allow passing previous metadata. // TODO(ashmrtn): Allow passing previous metadata.
cols, _, err := c.Get(ctx, nil) cols, delList, err := c.Get(ctx, nil)
test.errCheck(t, err) test.errCheck(t, err)
if err != nil { if err != nil {
@ -1424,9 +1424,7 @@ func (suite *OneDriveCollectionsSuite) TestGet() {
assert.ElementsMatch(t, test.expectedCollections[folderPath], itemIDs) assert.ElementsMatch(t, test.expectedCollections[folderPath], itemIDs)
} }
// TODO(ashmrtn): Uncomment this when we begin return the set of items to assert.Equal(t, test.expectedDelList, delList)
// remove from the upcoming backup.
// assert.Equal(t, test.expectedDelList, delList)
}) })
} }
} }

View File

@ -243,7 +243,7 @@ func (op *BackupOperation) do(
return nil, errors.Wrap(err, "connectng to m365") return nil, errors.Wrap(err, "connectng to m365")
} }
cs, err := produceBackupDataCollections(ctx, gc, op.Selectors, mdColls, op.Options) cs, excludes, err := produceBackupDataCollections(ctx, gc, op.Selectors, mdColls, op.Options)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "producing backup data collections") return nil, errors.Wrap(err, "producing backup data collections")
} }
@ -257,6 +257,7 @@ func (op *BackupOperation) do(
reasons, reasons,
mans, mans,
cs, cs,
excludes,
backupID, backupID,
op.incremental && canUseMetaData) op.incremental && canUseMetaData)
if err != nil { if err != nil {
@ -309,7 +310,7 @@ func produceBackupDataCollections(
sel selectors.Selector, sel selectors.Selector,
metadata []data.Collection, metadata []data.Collection,
ctrlOpts control.Options, ctrlOpts control.Options,
) ([]data.Collection, error) { ) ([]data.Collection, map[string]struct{}, error) {
complete, closer := observe.MessageWithCompletion(ctx, observe.Safe("Discovering items to backup")) complete, closer := observe.MessageWithCompletion(ctx, observe.Safe("Discovering items to backup"))
defer func() { defer func() {
complete <- struct{}{} complete <- struct{}{}
@ -317,11 +318,9 @@ func produceBackupDataCollections(
closer() closer()
}() }()
// TODO(ashmrtn): When we're ready to wire up the global exclude list return cols, excludes, errs := gc.DataCollections(ctx, sel, metadata, ctrlOpts)
// all values.
cols, _, errs := gc.DataCollections(ctx, sel, metadata, ctrlOpts)
return cols, errs return cols, excludes, errs
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -391,6 +390,7 @@ func consumeBackupDataCollections(
reasons []kopia.Reason, reasons []kopia.Reason,
mans []*kopia.ManifestEntry, mans []*kopia.ManifestEntry,
cs []data.Collection, cs []data.Collection,
excludes map[string]struct{},
backupID model.StableID, backupID model.StableID,
isIncremental bool, isIncremental bool,
) (*kopia.BackupStats, *details.Builder, map[string]path.Path, error) { ) (*kopia.BackupStats, *details.Builder, map[string]path.Path, error) {
@ -456,6 +456,8 @@ func consumeBackupDataCollections(
ctx, ctx,
bases, bases,
cs, cs,
// TODO(ashmrtn): When we're ready to enable incremental backups for
// OneDrive replace this with `excludes`.
nil, nil,
tags, tags,
isIncremental) isIncremental)

View File

@ -575,6 +575,7 @@ func (suite *BackupOpSuite) TestBackupOperation_ConsumeBackupDataCollections_Pat
nil, nil,
test.inputMan, test.inputMan,
nil, nil,
nil,
model.StableID(""), model.StableID(""),
true, true,
) )