From 0ce35f4f62ecfc23d7cab7ed9eb01a34f504deb9 Mon Sep 17 00:00:00 2001 From: Ashlie Martinez Date: Thu, 5 Oct 2023 11:08:16 -0700 Subject: [PATCH] Fixup references to sentinel error --- src/cli/backup/backup.go | 6 +++--- src/cli/export/export.go | 4 ++-- src/cli/restore/restore.go | 4 ++-- src/internal/data/implementations.go | 5 +++-- src/internal/data/item.go | 3 ++- src/internal/data/item_test.go | 3 ++- src/internal/data/mock/collection.go | 5 +++-- src/internal/kopia/base_finder_test.go | 6 +++--- src/internal/kopia/cleanup_backups.go | 4 ++-- src/internal/kopia/cleanup_backups_test.go | 10 +++++----- src/internal/kopia/data_collection.go | 5 +++-- src/internal/kopia/data_collection_test.go | 3 ++- src/internal/kopia/merge_collection.go | 7 ++++--- src/internal/kopia/merge_collection_test.go | 3 ++- src/internal/kopia/model_store.go | 8 ++++---- src/internal/kopia/model_store_test.go | 14 +++++++------- src/internal/kopia/upload.go | 3 ++- src/internal/kopia/wrapper.go | 3 ++- src/internal/kopia/wrapper_test.go | 3 ++- .../m365/collection/exchange/collection_test.go | 3 ++- src/internal/operations/manifests.go | 3 ++- src/internal/streamstore/collectables_test.go | 6 +++--- src/pkg/repository/backups.go | 4 ++-- src/pkg/repository/repository.go | 4 ++-- src/pkg/repository/repository_unexported_test.go | 16 ++++++++-------- 25 files changed, 74 insertions(+), 61 deletions(-) diff --git a/src/cli/backup/backup.go b/src/cli/backup/backup.go index 5d885e059..d5c4e7159 100644 --- a/src/cli/backup/backup.go +++ b/src/cli/backup/backup.go @@ -12,8 +12,8 @@ import ( "github.com/alcionai/corso/src/cli/flags" . "github.com/alcionai/corso/src/cli/print" "github.com/alcionai/corso/src/cli/utils" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/common/idname" - "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/m365/graph" "github.com/alcionai/corso/src/pkg/backup" "github.com/alcionai/corso/src/pkg/backup/details" @@ -307,7 +307,7 @@ func genericListCommand( if len(bID) > 0 { fe, b, errs := r.GetBackupErrors(ctx, bID) if errs.Failure() != nil { - if errors.Is(errs.Failure(), data.ErrNotFound) { + if errors.Is(errs.Failure(), errs.NotFound) { return Only(ctx, clues.New("No backup exists with the id "+bID)) } @@ -370,7 +370,7 @@ func genericDetailsCore( d, _, errs := bg.GetBackupDetails(ctx, backupID) // TODO: log/track recoverable errors if errs.Failure() != nil { - if errors.Is(errs.Failure(), data.ErrNotFound) { + if errors.Is(errs.Failure(), errs.NotFound) { return nil, clues.New("no backup exists with the id " + backupID) } diff --git a/src/cli/export/export.go b/src/cli/export/export.go index 8415caea3..e5f6cf0e3 100644 --- a/src/cli/export/export.go +++ b/src/cli/export/export.go @@ -11,7 +11,7 @@ import ( . "github.com/alcionai/corso/src/cli/print" "github.com/alcionai/corso/src/cli/utils" "github.com/alcionai/corso/src/internal/common/dttm" - "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/observe" "github.com/alcionai/corso/src/pkg/control" "github.com/alcionai/corso/src/pkg/export" @@ -93,7 +93,7 @@ func runExport( expColl, err := eo.Run(ctx) if err != nil { - if errors.Is(err, data.ErrNotFound) { + if errors.Is(err, errs.NotFound) { return Only(ctx, clues.New("Backup or backup details missing for id "+backupID)) } diff --git a/src/cli/restore/restore.go b/src/cli/restore/restore.go index 7db7dc5a7..8a137013b 100644 --- a/src/cli/restore/restore.go +++ b/src/cli/restore/restore.go @@ -10,7 +10,7 @@ import ( "github.com/alcionai/corso/src/cli/flags" . "github.com/alcionai/corso/src/cli/print" "github.com/alcionai/corso/src/cli/utils" - "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/pkg/count" "github.com/alcionai/corso/src/pkg/selectors" ) @@ -114,7 +114,7 @@ func runRestore( ds, err := ro.Run(ctx) if err != nil { - if errors.Is(err, data.ErrNotFound) { + if errors.Is(err, errs.NotFound) { return Only(ctx, clues.New("Backup or backup details missing for id "+flags.BackupIDFV)) } diff --git a/src/internal/data/implementations.go b/src/internal/data/implementations.go index c138ba6e6..5bc09d50d 100644 --- a/src/internal/data/implementations.go +++ b/src/internal/data/implementations.go @@ -3,6 +3,7 @@ package data import ( "context" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/pkg/control" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" @@ -23,13 +24,13 @@ type FetchRestoreCollection struct { } // NoFetchRestoreCollection is a wrapper for a Collection that returns -// ErrNotFound for all Fetch calls. +// errs.NotFound for all Fetch calls. type NoFetchRestoreCollection struct { Collection } func (c NoFetchRestoreCollection) FetchItemByName(context.Context, string) (Item, error) { - return nil, ErrNotFound + return nil, errs.NotFound } // StateOf lets us figure out the state of the collection from the diff --git a/src/internal/data/item.go b/src/internal/data/item.go index c6cb064e7..3962e0288 100644 --- a/src/internal/data/item.go +++ b/src/internal/data/item.go @@ -9,6 +9,7 @@ import ( "github.com/alcionai/clues" "github.com/spatialcurrent/go-lazy/pkg/lazy" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/common/readers" "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/fault" @@ -259,7 +260,7 @@ func (i *lazyItem) Info() (details.ItemInfo, error) { defer i.mu.Unlock() if i.delInFlight { - return details.ItemInfo{}, clues.Stack(ErrNotFound).WithClues(i.ctx) + return details.ItemInfo{}, clues.Stack(errs.NotFound).WithClues(i.ctx) } else if i.info == nil { return details.ItemInfo{}, clues.New("requesting ItemInfo before data retrieval"). WithClues(i.ctx) diff --git a/src/internal/data/item_test.go b/src/internal/data/item_test.go index f0c7e9009..35831dbe9 100644 --- a/src/internal/data/item_test.go +++ b/src/internal/data/item_test.go @@ -12,6 +12,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/common/readers" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/tester" @@ -376,7 +377,7 @@ func (suite *ItemUnitSuite) TestLazyItem_DeletedInFlight() { assert.Empty(t, readData, "read data") _, err = item.Info() - assert.ErrorIs(t, err, data.ErrNotFound, "Info() error") + assert.ErrorIs(t, err, errs.NotFound, "Info() error") e := errs.Errors() diff --git a/src/internal/data/mock/collection.go b/src/internal/data/mock/collection.go index 39a974e36..a1ab2c34d 100644 --- a/src/internal/data/mock/collection.go +++ b/src/internal/data/mock/collection.go @@ -9,6 +9,7 @@ import ( "github.com/alcionai/clues" "github.com/stretchr/testify/require" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/common/readers" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/pkg/backup/details" @@ -144,7 +145,7 @@ func (c Collection) FetchItemByName( ) (data.Item, error) { res := c.AuxItems[name] if res == nil { - return nil, data.ErrNotFound + return nil, errs.NotFound } return res, nil @@ -163,7 +164,7 @@ func (rc RestoreCollection) FetchItemByName( ) (data.Item, error) { res := rc.AuxItems[name] if res == nil { - return nil, data.ErrNotFound + return nil, errs.NotFound } return res, nil diff --git a/src/internal/kopia/base_finder_test.go b/src/internal/kopia/base_finder_test.go index b9098d2d3..aff02a88e 100644 --- a/src/internal/kopia/base_finder_test.go +++ b/src/internal/kopia/base_finder_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/model" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/backup" @@ -91,7 +91,7 @@ func (mg mockEmptyModelGetter) GetBackup( context.Context, model.StableID, ) (*backup.Backup, error) { - return nil, data.ErrNotFound + return nil, errs.NotFound } // ----------------------------------------------------------------------------- @@ -269,7 +269,7 @@ func (mg mockModelGetter) GetBackup( return &res, nil } - return nil, data.ErrNotFound + return nil, errs.NotFound } // ----------------------------------------------------------------------------- diff --git a/src/internal/kopia/cleanup_backups.go b/src/internal/kopia/cleanup_backups.go index f46f4c453..b1231723a 100644 --- a/src/internal/kopia/cleanup_backups.go +++ b/src/internal/kopia/cleanup_backups.go @@ -12,7 +12,7 @@ import ( "golang.org/x/exp/maps" "golang.org/x/exp/slices" - "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/model" "github.com/alcionai/corso/src/pkg/backup" "github.com/alcionai/corso/src/pkg/logger" @@ -160,7 +160,7 @@ func cleanupOrphanedData( model.BackupSchema, bup.ModelStoreID, &bm); err != nil { - if !errors.Is(err, data.ErrNotFound) { + if !errors.Is(err, errs.NotFound) { return clues.Wrap(err, "getting backup model"). With("search_backup_id", bup.ID) } diff --git a/src/internal/kopia/cleanup_backups_test.go b/src/internal/kopia/cleanup_backups_test.go index eb5fe8ac9..5b74bada9 100644 --- a/src/internal/kopia/cleanup_backups_test.go +++ b/src/internal/kopia/cleanup_backups_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/model" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/backup" @@ -116,7 +116,7 @@ func (ms mockStorer) GetWithModelStoreID( } } - return clues.Stack(data.ErrNotFound) + return clues.Stack(errs.NotFound) } func (ms mockStorer) DeleteWithModelStoreIDs( @@ -518,11 +518,11 @@ func (suite *BackupCleanupUnitSuite) TestCleanupOrphanedData() { {bup: bupCurrent()}, { bup: bupLegacy(), - err: data.ErrNotFound, + err: errs.NotFound, }, { bup: bupNoDetails(), - err: data.ErrNotFound, + err: errs.NotFound, }, }, // Backup IDs are still included in here because they're added to the @@ -623,7 +623,7 @@ func (suite *BackupCleanupUnitSuite) TestCleanupOrphanedData() { backups: []backupRes{ { bup: backupWithTime(baseTime, bupCurrent()), - err: data.ErrNotFound, + err: errs.NotFound, }, }, time: baseTime, diff --git a/src/internal/kopia/data_collection.go b/src/internal/kopia/data_collection.go index c5899afdf..fd247535f 100644 --- a/src/internal/kopia/data_collection.go +++ b/src/internal/kopia/data_collection.go @@ -7,6 +7,7 @@ import ( "github.com/alcionai/clues" "github.com/kopia/kopia/fs" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/common/readers" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/pkg/fault" @@ -74,7 +75,7 @@ func (kdc kopiaDataCollection) FullPath() path.Path { } // Fetch returns the file with the given name from the collection as a -// data.Item. Returns a data.ErrNotFound error if the file isn't in the +// data.Item. Returns a errs.NotFound error if the file isn't in the // collection. func (kdc kopiaDataCollection) FetchItemByName( ctx context.Context, @@ -93,7 +94,7 @@ func (kdc kopiaDataCollection) FetchItemByName( e, err := kdc.dir.Child(ctx, encodeAsPath(name)) if err != nil { if isErrEntryNotFound(err) { - err = clues.Stack(data.ErrNotFound, err) + err = clues.Stack(errs.NotFound, err) } return nil, clues.Wrap(err, "getting item").WithClues(ctx) diff --git a/src/internal/kopia/data_collection_test.go b/src/internal/kopia/data_collection_test.go index 4b1b4a4b2..4d5a06df7 100644 --- a/src/internal/kopia/data_collection_test.go +++ b/src/internal/kopia/data_collection_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/common/readers" "github.com/alcionai/corso/src/internal/data" dataMock "github.com/alcionai/corso/src/internal/data/mock" @@ -410,7 +411,7 @@ func (suite *KopiaDataCollectionUnitSuite) TestFetchItemByName() { if err != nil { if test.notFoundErr { - assert.ErrorIs(t, err, data.ErrNotFound, clues.ToCore(err)) + assert.ErrorIs(t, err, errs.NotFound, clues.ToCore(err)) } return diff --git a/src/internal/kopia/merge_collection.go b/src/internal/kopia/merge_collection.go index 13a470b87..a232295a2 100644 --- a/src/internal/kopia/merge_collection.go +++ b/src/internal/kopia/merge_collection.go @@ -7,6 +7,7 @@ import ( "github.com/alcionai/clues" "golang.org/x/exp/slices" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/logger" @@ -92,7 +93,7 @@ func (mc *mergeCollection) Items( } // Fetch goes through all the collections in this one and returns the first -// match found or the first error that is not data.ErrNotFound. If multiple +// match found or the first error that is not errs.NotFound. If multiple // collections have the requested item, the instance in the collection with the // lexicographically smallest storage path is returned. func (mc *mergeCollection) FetchItemByName( @@ -113,11 +114,11 @@ func (mc *mergeCollection) FetchItemByName( s, err := c.FetchItemByName(ictx, name) if err == nil { return s, nil - } else if err != nil && !errors.Is(err, data.ErrNotFound) { + } else if err != nil && !errors.Is(err, errs.NotFound) { return nil, clues.Wrap(err, "fetching from merged collection"). WithClues(ictx) } } - return nil, clues.Wrap(data.ErrNotFound, "merged collection fetch") + return nil, clues.Wrap(errs.NotFound, "merged collection fetch") } diff --git a/src/internal/kopia/merge_collection_test.go b/src/internal/kopia/merge_collection_test.go index fefbfbb15..68fb8bc1b 100644 --- a/src/internal/kopia/merge_collection_test.go +++ b/src/internal/kopia/merge_collection_test.go @@ -12,6 +12,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/common/readers" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/m365/service/exchange/mock" @@ -292,7 +293,7 @@ func (suite *MergeCollectionUnitSuite) TestFetchItemByName() { if err != nil { if test.notFoundErr { - assert.ErrorIs(t, err, data.ErrNotFound, clues.ToCore(err)) + assert.ErrorIs(t, err, errs.NotFound, clues.ToCore(err)) } return diff --git a/src/internal/kopia/model_store.go b/src/internal/kopia/model_store.go index e68756d63..3c3b8ea88 100644 --- a/src/internal/kopia/model_store.go +++ b/src/internal/kopia/model_store.go @@ -11,7 +11,7 @@ import ( "github.com/pkg/errors" "golang.org/x/exp/maps" - "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/model" "github.com/alcionai/corso/src/pkg/store" ) @@ -292,7 +292,7 @@ func (ms *ModelStore) getModelStoreID( } if len(metadata) == 0 { - return "", clues.Wrap(data.ErrNotFound, "getting ModelStoreID").WithClues(ctx) + return "", clues.Wrap(errs.NotFound, "getting ModelStoreID").WithClues(ctx) } if len(metadata) != 1 { @@ -347,7 +347,7 @@ func (ms *ModelStore) GetWithModelStoreID( metadata, err := ms.c.GetManifest(ctx, id, m) if err != nil { if errors.Is(err, manifest.ErrNotFound) { - err = data.ErrNotFound + err = errs.NotFound } return clues.Wrap(err, "getting model data").WithClues(ctx) @@ -490,7 +490,7 @@ func (ms *ModelStore) Delete(ctx context.Context, s model.Schema, id model.Stabl latest, err := ms.getModelStoreID(ctx, s, id) if err != nil { - if errors.Is(err, data.ErrNotFound) { + if errors.Is(err, errs.NotFound) { return nil } diff --git a/src/internal/kopia/model_store_test.go b/src/internal/kopia/model_store_test.go index db25eee57..5f4b510fc 100644 --- a/src/internal/kopia/model_store_test.go +++ b/src/internal/kopia/model_store_test.go @@ -14,7 +14,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/model" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/backup" @@ -381,10 +381,10 @@ func (suite *ModelStoreIntegrationSuite) TestGet_NotFoundErrors() { t := suite.T() err := suite.m.Get(suite.ctx, model.BackupOpSchema, "baz", nil) - assert.ErrorIs(t, err, data.ErrNotFound, clues.ToCore(err)) + assert.ErrorIs(t, err, errs.NotFound, clues.ToCore(err)) err = suite.m.GetWithModelStoreID(suite.ctx, model.BackupOpSchema, "baz", nil) - assert.ErrorIs(t, err, data.ErrNotFound, clues.ToCore(err)) + assert.ErrorIs(t, err, errs.NotFound, clues.ToCore(err)) } func (suite *ModelStoreIntegrationSuite) TestPutGetOfTypeBadVersion() { @@ -670,7 +670,7 @@ func (suite *ModelStoreIntegrationSuite) TestPutUpdate() { } err = m.GetWithModelStoreID(ctx, theModelType, oldModelID, nil) - assert.ErrorIs(t, err, data.ErrNotFound, clues.ToCore(err)) + assert.ErrorIs(t, err, errs.NotFound, clues.ToCore(err)) }) } } @@ -737,7 +737,7 @@ func (suite *ModelStoreIntegrationSuite) TestPutDelete() { returned := &fooModel{} err = suite.m.GetWithModelStoreID(suite.ctx, theModelType, foo.ModelStoreID, returned) - assert.ErrorIs(t, err, data.ErrNotFound, clues.ToCore(err)) + assert.ErrorIs(t, err, errs.NotFound, clues.ToCore(err)) } func (suite *ModelStoreIntegrationSuite) TestPutDeleteBatch() { @@ -760,7 +760,7 @@ func (suite *ModelStoreIntegrationSuite) TestPutDeleteBatch() { for _, id := range ids { returned := &fooModel{} err := suite.m.GetWithModelStoreID(suite.ctx, theModelType, id, returned) - assert.ErrorIs(t, err, data.ErrNotFound, clues.ToCore(err)) + assert.ErrorIs(t, err, errs.NotFound, clues.ToCore(err)) } } @@ -843,7 +843,7 @@ func (suite *ModelStoreRegressionSuite) TestFailDuringWriteSessionHasNoVisibleEf assert.ErrorIs(t, err, assert.AnError, clues.ToCore(err)) err = m.GetWithModelStoreID(ctx, theModelType, newID, nil) - assert.ErrorIs(t, err, data.ErrNotFound, clues.ToCore(err)) + assert.ErrorIs(t, err, errs.NotFound, clues.ToCore(err)) returned := &fooModel{} diff --git a/src/internal/kopia/upload.go b/src/internal/kopia/upload.go index e76dffd60..0641d935e 100644 --- a/src/internal/kopia/upload.go +++ b/src/internal/kopia/upload.go @@ -17,6 +17,7 @@ import ( "github.com/kopia/kopia/snapshot/snapshotfs" "golang.org/x/exp/maps" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/common/prefixmatcher" "github.com/alcionai/corso/src/internal/common/ptr" "github.com/alcionai/corso/src/internal/data" @@ -133,7 +134,7 @@ func (cp *corsoProgress) FinishedFile(relativePath string, err error) { } info, err := d.infoer.Info() - if errors.Is(err, data.ErrNotFound) { + if errors.Is(err, errs.NotFound) { // The item was deleted between enumeration and trying to get data. Skip // adding it to details since there's no data for it. return diff --git a/src/internal/kopia/wrapper.go b/src/internal/kopia/wrapper.go index ddb6acacf..741f7c532 100644 --- a/src/internal/kopia/wrapper.go +++ b/src/internal/kopia/wrapper.go @@ -17,6 +17,7 @@ import ( "github.com/kopia/kopia/snapshot/snapshotmaintenance" "golang.org/x/exp/maps" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/common/prefixmatcher" "github.com/alcionai/corso/src/internal/common/readers" "github.com/alcionai/corso/src/internal/data" @@ -370,7 +371,7 @@ func getDir( encodeElements(dirPath.PopFront().Elements()...)) if err != nil { if isErrEntryNotFound(err) { - err = clues.Stack(data.ErrNotFound, err).WithClues(ctx) + err = clues.Stack(errs.NotFound, err).WithClues(ctx) } return nil, clues.Wrap(err, "getting nested object handle").WithClues(ctx) diff --git a/src/internal/kopia/wrapper_test.go b/src/internal/kopia/wrapper_test.go index 7133fea50..7c25f21e8 100644 --- a/src/internal/kopia/wrapper_test.go +++ b/src/internal/kopia/wrapper_test.go @@ -21,6 +21,7 @@ import ( "github.com/stretchr/testify/suite" "golang.org/x/exp/maps" + "github.com/alcionai/corso/src/internal/common/errs" pmMock "github.com/alcionai/corso/src/internal/common/prefixmatcher/mock" "github.com/alcionai/corso/src/internal/common/ptr" "github.com/alcionai/corso/src/internal/data" @@ -1398,7 +1399,7 @@ func (suite *KopiaIntegrationSuite) TestBackupCollections_ReaderError() { // Files that had an error shouldn't make a dir entry in kopia. If they do we // may run into kopia-assisted incrementals issues because only mod time and // not file size is checked for StreamingFiles. - assert.ErrorIs(t, errs.Failure(), data.ErrNotFound, "errored file is restorable", clues.ToCore(err)) + assert.ErrorIs(t, errs.Failure(), errs.NotFound, "errored file is restorable", clues.ToCore(err)) } type backedupFile struct { diff --git a/src/internal/m365/collection/exchange/collection_test.go b/src/internal/m365/collection/exchange/collection_test.go index f373bd1a5..5a183c92c 100644 --- a/src/internal/m365/collection/exchange/collection_test.go +++ b/src/internal/m365/collection/exchange/collection_test.go @@ -16,6 +16,7 @@ import ( "golang.org/x/exp/maps" "golang.org/x/exp/slices" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/common/ptr" "github.com/alcionai/corso/src/internal/common/readers" "github.com/alcionai/corso/src/internal/data" @@ -625,7 +626,7 @@ func (suite *CollectionUnitSuite) TestLazyItem_ReturnsEmptyReaderOnDeletedInFlig assert.Empty(t, readData, "read item data") _, err = li.Info() - assert.ErrorIs(t, err, data.ErrNotFound, "Info() error") + assert.ErrorIs(t, err, errs.NotFound, "Info() error") } func (suite *CollectionUnitSuite) TestLazyItem() { diff --git a/src/internal/operations/manifests.go b/src/internal/operations/manifests.go index 4b6e6fe4e..37dee4cf1 100644 --- a/src/internal/operations/manifests.go +++ b/src/internal/operations/manifests.go @@ -6,6 +6,7 @@ import ( "github.com/alcionai/clues" "github.com/pkg/errors" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/kopia" "github.com/alcionai/corso/src/internal/kopia/inject" @@ -128,7 +129,7 @@ func getManifestsAndMetadata( // should be safe to leave this manifest in the AssistBases set, though we // could remove it there too if we want to be conservative. That can be done // by finding the manifest ID. - if err != nil && !errors.Is(err, data.ErrNotFound) { + if err != nil && !errors.Is(err, errs.NotFound) { // prior metadata isn't guaranteed to exist. // if it doesn't, we'll just have to do a // full backup for that data. diff --git a/src/internal/streamstore/collectables_test.go b/src/internal/streamstore/collectables_test.go index 5257ee718..78dcc0178 100644 --- a/src/internal/streamstore/collectables_test.go +++ b/src/internal/streamstore/collectables_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/kopia" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/backup/details" @@ -207,7 +207,7 @@ func (suite *StreamStoreIntgSuite) TestStreamer() { snapid, DetailsReader(details.UnmarshalTo(&readDeets)), fault.New(true)) - assert.ErrorIs(t, err, data.ErrNotFound) + assert.ErrorIs(t, err, errs.NotFound) assert.Empty(t, readDeets) } @@ -229,7 +229,7 @@ func (suite *StreamStoreIntgSuite) TestStreamer() { snapid, FaultErrorsReader(fault.UnmarshalErrorsTo(&readErrs)), fault.New(true)) - assert.ErrorIs(t, err, data.ErrNotFound) + assert.ErrorIs(t, err, errs.NotFound) assert.Empty(t, readErrs) } }) diff --git a/src/pkg/repository/backups.go b/src/pkg/repository/backups.go index a4314eb01..2920f42d0 100644 --- a/src/pkg/repository/backups.go +++ b/src/pkg/repository/backups.go @@ -7,8 +7,8 @@ import ( "github.com/kopia/kopia/repo/manifest" "github.com/pkg/errors" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/common/idname" - "github.com/alcionai/corso/src/internal/data" "github.com/alcionai/corso/src/internal/kopia" "github.com/alcionai/corso/src/internal/m365/collection/drive/metadata" "github.com/alcionai/corso/src/internal/model" @@ -330,7 +330,7 @@ func deleteBackups( for _, id := range ids { b, err := sw.GetBackup(ctx, model.StableID(id)) if err != nil { - if !failOnMissing && errors.Is(err, data.ErrNotFound) { + if !failOnMissing && errors.Is(err, errs.NotFound) { continue } diff --git a/src/pkg/repository/repository.go b/src/pkg/repository/repository.go index 283af8e56..9b9556f6b 100644 --- a/src/pkg/repository/repository.go +++ b/src/pkg/repository/repository.go @@ -9,7 +9,7 @@ import ( "github.com/pkg/errors" "github.com/alcionai/corso/src/internal/common/crash" - "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/events" "github.com/alcionai/corso/src/internal/kopia" "github.com/alcionai/corso/src/internal/model" @@ -385,7 +385,7 @@ func newRepoID(s storage.Storage) string { // --------------------------------------------------------------------------- func errWrapper(err error) error { - if errors.Is(err, data.ErrNotFound) { + if errors.Is(err, errs.NotFound) { return clues.Stack(ErrorBackupNotFound, err) } diff --git a/src/pkg/repository/repository_unexported_test.go b/src/pkg/repository/repository_unexported_test.go index f3582c8b4..7cada148d 100644 --- a/src/pkg/repository/repository_unexported_test.go +++ b/src/pkg/repository/repository_unexported_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/common/errs" "github.com/alcionai/corso/src/internal/kopia" "github.com/alcionai/corso/src/internal/model" "github.com/alcionai/corso/src/internal/operations" @@ -107,11 +107,11 @@ func (suite *RepositoryBackupsUnitSuite) TestGetBackup() { name: "get error", sw: mock.BackupWrapper{ Backup: bup, - GetErr: data.ErrNotFound, + GetErr: errs.NotFound, DeleteErr: nil, }, expectErr: func(t *testing.T, result error) { - assert.ErrorIs(t, result, data.ErrNotFound, clues.ToCore(result)) + assert.ErrorIs(t, result, errs.NotFound, clues.ToCore(result)) assert.ErrorIs(t, result, ErrorBackupNotFound, clues.ToCore(result)) }, expectID: bup.ID, @@ -446,14 +446,14 @@ func (suite *RepositoryBackupsUnitSuite) TestDeleteBackups() { bup.ID, }, gets: []getRes{ - {err: data.ErrNotFound}, + {err: errs.NotFound}, }, expectGets: []model.StableID{ bup.ID, }, failOnMissing: true, expectErr: func(t *testing.T, result error) { - assert.ErrorIs(t, result, data.ErrNotFound, clues.ToCore(result)) + assert.ErrorIs(t, result, errs.NotFound, clues.ToCore(result)) assert.ErrorIs(t, result, ErrorBackupNotFound, clues.ToCore(result)) }, }, @@ -598,7 +598,7 @@ func (suite *RepositoryBackupsUnitSuite) TestDeleteBackups() { {bup: bup}, {bup: bupLegacy}, {bup: bupNoSnapshot}, - {err: data.ErrNotFound}, + {err: errs.NotFound}, }, expectGets: []model.StableID{ bup.ID, @@ -608,7 +608,7 @@ func (suite *RepositoryBackupsUnitSuite) TestDeleteBackups() { }, failOnMissing: true, expectErr: func(t *testing.T, result error) { - assert.ErrorIs(t, result, data.ErrNotFound, clues.ToCore(result)) + assert.ErrorIs(t, result, errs.NotFound, clues.ToCore(result)) assert.ErrorIs(t, result, ErrorBackupNotFound, clues.ToCore(result)) }, }, @@ -622,7 +622,7 @@ func (suite *RepositoryBackupsUnitSuite) TestDeleteBackups() { }, gets: []getRes{ {bup: bup}, - {err: data.ErrNotFound}, + {err: errs.NotFound}, {bup: bupNoSnapshot}, {bup: bupNoDetails}, },