diff --git a/src/internal/connector/graph_connector.go b/src/internal/connector/graph_connector.go index 0e2205496..d62cd2bd8 100644 --- a/src/internal/connector/graph_connector.go +++ b/src/internal/connector/graph_connector.go @@ -224,7 +224,7 @@ func (gc *GraphConnector) UnionSiteIDsAndWebURLs( } // AwaitStatus waits for all gc tasks to complete and then returns status -func (gc *GraphConnector) Wait() data.CollectionStats { +func (gc *GraphConnector) Wait() *data.CollectionStats { defer func() { if gc.region != nil { gc.region.End() @@ -245,7 +245,7 @@ func (gc *GraphConnector) Wait() data.CollectionStats { gc.wg = &sync.WaitGroup{} gc.status = support.ConnectorOperationStatus{} - return dcs + return &dcs } // UpdateStatus is used by gc initiated tasks to indicate completion diff --git a/src/internal/connector/mockconnector/mock_data_connector.go b/src/internal/connector/mockconnector/mock_data_connector.go index 583dd8e32..453345a2c 100644 --- a/src/internal/connector/mockconnector/mock_data_connector.go +++ b/src/internal/connector/mockconnector/mock_data_connector.go @@ -37,8 +37,8 @@ func (gc GraphConnector) ProduceBackupCollections( return gc.Collections, gc.Exclude, gc.Err } -func (gc GraphConnector) Wait() data.CollectionStats { - return gc.Stats +func (gc GraphConnector) Wait() *data.CollectionStats { + return &gc.Stats } func (gc GraphConnector) ConsumeRestoreCollections( diff --git a/src/internal/operations/backup.go b/src/internal/operations/backup.go index 874d39197..18032b3c2 100644 --- a/src/internal/operations/backup.go +++ b/src/internal/operations/backup.go @@ -73,6 +73,7 @@ func NewBackupOperation( Version: "v0", account: acct, incremental: useIncrementalBackup(selector, opts), + bp: bp, } if len(ownerName) == 0 { @@ -104,7 +105,7 @@ func (op BackupOperation) validate() error { // get populated asynchronously. type backupStats struct { k *kopia.BackupStats - gc data.CollectionStats + gc *data.CollectionStats resourceCount int } @@ -331,7 +332,7 @@ type BackupProducer interface { ) ([]data.BackupCollection, map[string]map[string]struct{}, error) // TODO: ConnectorOperationStatus should be replaced with something // more generic. - Wait() data.CollectionStats + Wait() *data.CollectionStats } // calls the producer to generate collections of data to backup @@ -684,12 +685,12 @@ func (op *BackupOperation) persistResults( op.Results.ItemsWritten = opStats.k.TotalFileCount op.Results.ResourceOwners = opStats.resourceCount - if opStats.gc.IsZero() { + if opStats.gc == nil { op.Status = Failed return clues.New("backup population never completed") } - if op.Status != Failed && opStats.gc.Successes == 0 { + if op.Status != Failed && opStats.gc.IsZero() { op.Status = NoData } diff --git a/src/internal/operations/backup_test.go b/src/internal/operations/backup_test.go index 14c087130..ace1d53ae 100644 --- a/src/internal/operations/backup_test.go +++ b/src/internal/operations/backup_test.go @@ -380,7 +380,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_PersistResults() { TotalHashedBytes: 1, TotalUploadedBytes: 1, }, - gc: data.CollectionStats{Successes: 1}, + gc: &data.CollectionStats{Successes: 1}, }, }, { @@ -389,7 +389,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_PersistResults() { fail: assert.AnError, stats: backupStats{ k: &kopia.BackupStats{}, - gc: data.CollectionStats{}, + gc: &data.CollectionStats{}, }, }, { @@ -397,7 +397,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_PersistResults() { expectErr: assert.NoError, stats: backupStats{ k: &kopia.BackupStats{}, - gc: data.CollectionStats{}, + gc: &data.CollectionStats{}, }, }, } diff --git a/src/internal/operations/restore.go b/src/internal/operations/restore.go index 4def27c82..699087033 100644 --- a/src/internal/operations/restore.go +++ b/src/internal/operations/restore.go @@ -93,7 +93,7 @@ func (op RestoreOperation) validate() error { // get populated asynchronously. type restoreStats struct { cs []data.RestoreCollection - gc data.CollectionStats + gc *data.CollectionStats bytesRead *stats.ByteCounter resourceCount int @@ -280,12 +280,12 @@ func (op *RestoreOperation) persistResults( op.Results.ItemsRead = len(opStats.cs) // TODO: file count, not collection count op.Results.ResourceOwners = opStats.resourceCount - if opStats.gc.IsZero() { + if opStats.gc == nil { op.Status = Failed return clues.New("restoration never completed") } - if op.Status != Failed && opStats.gc.Successes == 0 { + if op.Status != Failed && opStats.gc.IsZero() { op.Status = NoData } @@ -329,7 +329,7 @@ type RestoreConsumer interface { ) (*details.Details, error) // TODO: ConnectorOperationStatus should be replaced with something // more generic. - Wait() data.CollectionStats + Wait() *data.CollectionStats } func consumeRestoreCollections( diff --git a/src/internal/operations/restore_test.go b/src/internal/operations/restore_test.go index 97f2715f2..61fcf6723 100644 --- a/src/internal/operations/restore_test.go +++ b/src/internal/operations/restore_test.go @@ -74,7 +74,7 @@ func (suite *RestoreOpSuite) TestRestoreOperation_PersistResults() { Collection: &mockconnector.MockExchangeDataCollection{}, }, }, - gc: data.CollectionStats{ + gc: &data.CollectionStats{ Objects: 1, Successes: 1, }, @@ -86,7 +86,7 @@ func (suite *RestoreOpSuite) TestRestoreOperation_PersistResults() { fail: assert.AnError, stats: restoreStats{ bytesRead: &stats.ByteCounter{}, - gc: data.CollectionStats{}, + gc: &data.CollectionStats{}, }, }, { @@ -95,7 +95,7 @@ func (suite *RestoreOpSuite) TestRestoreOperation_PersistResults() { stats: restoreStats{ bytesRead: &stats.ByteCounter{}, cs: []data.RestoreCollection{}, - gc: data.CollectionStats{}, + gc: &data.CollectionStats{}, }, }, }