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.
return collections, nil, nil
return collections, excludedItems, nil
}
// UpdateCollections initializes and adds the provided drive items to Collections

View File

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

View File

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

View File

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