diff --git a/CHANGELOG.md b/CHANGELOG.md index c85ae536d..259289b6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - --user and --mailbox flags have been removed from CLI examples for details and restore commands (they were already not supported, this only updates the docs). - Improve restore time on large restores by optimizing how items are loaded from the remote repository. - Remove exchange item filtering based on m365 item ID via the CLI. +- OneDrive backups no longer include a user's non-default drives. ## [v0.7.0] (beta) - 2023-05-02 diff --git a/src/internal/connector/onedrive/api/drive.go b/src/internal/connector/onedrive/api/drive.go index 3567ece4c..3b2674553 100644 --- a/src/internal/connector/onedrive/api/drive.go +++ b/src/internal/connector/onedrive/api/drive.go @@ -104,6 +104,7 @@ func (p *driveItemPager) ValuesIn(l api.DeltaPageLinker) ([]models.DriveItemable } type userDrivePager struct { + userID string gs graph.Servicer builder *users.ItemDrivesRequestBuilder options *users.ItemDrivesRequestBuilderGetRequestConfiguration @@ -121,6 +122,7 @@ func NewUserDrivePager( } res := &userDrivePager{ + userID: userID, gs: gs, options: requestConfig, builder: gs.Client().UsersById(userID).Drives(), @@ -129,17 +131,33 @@ func NewUserDrivePager( return res } +type nopUserDrivePageLinker struct { + drive models.Driveable +} + +func (nl nopUserDrivePageLinker) GetOdataNextLink() *string { return nil } + func (p *userDrivePager) GetPage(ctx context.Context) (api.PageLinker, error) { var ( resp api.PageLinker err error ) - resp, err = p.builder.Get(ctx, p.options) + d, err := p.gs.Client().UsersById(p.userID).Drive().Get(ctx, nil) if err != nil { return nil, graph.Stack(ctx, err) } + resp = &nopUserDrivePageLinker{drive: d} + + // TODO(keepers): turn back on when we can separate drive enumeration + // from default drive lookup. + + // resp, err = p.builder.Get(ctx, p.options) + // if err != nil { + // return nil, graph.Stack(ctx, err) + // } + return resp, nil } @@ -148,7 +166,17 @@ func (p *userDrivePager) SetNext(link string) { } func (p *userDrivePager) ValuesIn(l api.PageLinker) ([]models.Driveable, error) { - return getValues[models.Driveable](l) + nl, ok := l.(*nopUserDrivePageLinker) + if !ok || nl == nil { + return nil, clues.New(fmt.Sprintf("improper page linker struct for user drives: %T", l)) + } + + // TODO(keepers): turn back on when we can separate drive enumeration + // from default drive lookup. + + // return getValues[models.Driveable](l) + + return []models.Driveable{nl.drive}, nil } type siteDrivePager struct {