From 3442c1f0ee77d88e23a5beb29f0cb41075da6ad2 Mon Sep 17 00:00:00 2001 From: Vaibhav Kamra Date: Fri, 6 Oct 2023 15:05:59 -0700 Subject: [PATCH] More fixes --- src/cli/backup/backup.go | 7 +++++- src/internal/m365/backup.go | 18 ++++++-------- src/internal/operations/inject/containers.go | 26 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/cli/backup/backup.go b/src/cli/backup/backup.go index e6db47210..52c02c8b6 100644 --- a/src/cli/backup/backup.go +++ b/src/cli/backup/backup.go @@ -217,7 +217,8 @@ func genericCreateCommand( if bo.Options.DryRun { // Print backup stats results here - print.All(ctx, bo.Results.Stats) + Info(ctx, "Discovered data:\n") + print.Item(ctx, bo.Results.Stats) continue } @@ -231,6 +232,10 @@ func genericCreateCommand( } } + if flags.RunModeFV == flags.RunModeDryRun { + return nil + } + bups, berrs := r.Backups(ctx, bIDs) if berrs.Failure() != nil { return Only(ctx, clues.Wrap(berrs.Failure(), "Unable to retrieve backup results from storage")) diff --git a/src/internal/m365/backup.go b/src/internal/m365/backup.go index 78921106e..f5756c0e4 100644 --- a/src/internal/m365/backup.go +++ b/src/internal/m365/backup.go @@ -5,7 +5,6 @@ import ( "github.com/alcionai/clues" - "github.com/alcionai/corso/src/internal/common/prefixmatcher" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/diagnostics" "github.com/alcionai/corso/src/internal/kopia" @@ -57,10 +56,10 @@ func (ctrl *Controller) ProduceBackupCollections( } var ( - colls []data.BackupCollection - ssmb *prefixmatcher.StringSetMatcher - canUsePreviousBackup bool - results inject.BackupProducerResults + // colls []data.BackupCollection + // ssmb *prefixmatcher.StringSetMatcher + // canUsePreviousBackup bool + results inject.BackupProducerResults ) switch service { @@ -89,7 +88,7 @@ func (ctrl *Controller) ProduceBackupCollections( } case path.SharePointService: - colls, ssmb, canUsePreviousBackup, err = sharepoint.ProduceBackupCollections( + colls, ssmb, canUsePreviousBackup, err := sharepoint.ProduceBackupCollections( ctx, bpc, ctrl.AC, @@ -102,7 +101,7 @@ func (ctrl *Controller) ProduceBackupCollections( results = inject.BackupProducerResults{Collections: colls, Excludes: ssmb, CanUsePreviousBackup: canUsePreviousBackup} case path.GroupsService: - colls, ssmb, err = groups.ProduceBackupCollections( + colls, ssmb, err := groups.ProduceBackupCollections( ctx, bpc, ctrl.AC, @@ -115,13 +114,12 @@ func (ctrl *Controller) ProduceBackupCollections( // canUsePreviousBacukp can be always returned true for groups as we // return a tombstone collection in case the metadata read fails - canUsePreviousBackup = true - results = inject.BackupProducerResults{Collections: colls, Excludes: ssmb, CanUsePreviousBackup: canUsePreviousBackup} + results = inject.BackupProducerResults{Collections: colls, Excludes: ssmb, CanUsePreviousBackup: true} default: return inject.BackupProducerResults{}, clues.Wrap(clues.New(service.String()), "service not supported").WithClues(ctx) } - for _, c := range colls { + for _, c := range results.Collections { // kopia doesn't stream Items() from deleted collections, // and so they never end up calling the UpdateStatus closer. // This is a brittle workaround, since changes in consumer diff --git a/src/internal/operations/inject/containers.go b/src/internal/operations/inject/containers.go index baba6616e..568aa6568 100644 --- a/src/internal/operations/inject/containers.go +++ b/src/internal/operations/inject/containers.go @@ -90,6 +90,19 @@ func (s Stats) MinimumPrintable() any { // for printing out to a terminal in a columnar display. func (s Stats) Headers() []string { switch { + case s.Exchange != nil: + return []string{ + "EmailsAdded", + "EmailsDeleted", + "EmailFolders", + "ContactsAdded", + "ContactsDeleted", + "ContactFolders", + "EventsAdded", + "EventsDeleted", + "EventFolders", + } + case s.OneDrive != nil: return []string{ "Folders", @@ -105,6 +118,19 @@ func (s Stats) Headers() []string { // out to a terminal in a columnar display. func (s Stats) Values() []string { switch { + case s.Exchange != nil: + return []string{ + strconv.Itoa(s.Exchange.EmailsAdded), + strconv.Itoa(s.Exchange.EmailsDeleted), + strconv.Itoa(s.Exchange.EmailFolders), + strconv.Itoa(s.Exchange.ContactsAdded), + strconv.Itoa(s.Exchange.ContactsDeleted), + strconv.Itoa(s.Exchange.ContactFolders), + strconv.Itoa(s.Exchange.EventsAdded), + strconv.Itoa(s.Exchange.EventsDeleted), + strconv.Itoa(s.Exchange.EventFolders), + } + case s.OneDrive != nil: return []string{ strconv.Itoa(s.OneDrive.Folders),