Skip to content

Commit 40ca0b4

Browse files
committed
fixup
1 parent bf91194 commit 40ca0b4

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

db/background_mgr_resync_dcp.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,17 @@ func (r *ResyncManagerDCP) Init(ctx context.Context, options map[string]any, clu
8181
return errors.New("collections option is required and must be of type base.CollectionNames")
8282
}
8383

84-
// Get collectionIds and store in manager for use in DCP client later
85-
collections, err := getResyncCollections(db, resyncCollections)
86-
if err != nil {
87-
return err
84+
var collections DatabaseCollections
85+
if len(resyncCollections) > 0 {
86+
var err error
87+
collections, err = db.collections(resyncCollections)
88+
if err != nil {
89+
return err
90+
}
91+
} else {
92+
collections = slices.Collect(maps.Values(db.CollectionByID))
93+
r.hasAllCollections = true
8894
}
89-
r.hasAllCollections = len(resyncCollections) == 0
9095
// add collection list to manager for use in status call
9196
r.setCollectionStatus(collections)
9297

@@ -443,7 +448,6 @@ func (r *ResyncManagerDCP) Run(ctx context.Context, options map[string]any, pers
443448
return nil
444449
}
445450

446-
// getResyncCollections returns collections requested for resync. If no collections are specified, it returns all collections.
447451
func getResyncCollections(db *Database, resyncCollections base.CollectionNames) (collections DatabaseCollections, err error) {
448452
if len(resyncCollections) == 0 {
449453
return slices.Collect(maps.Values(db.CollectionByID)), nil

db/database.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2615,3 +2615,18 @@ func (db *DatabaseContext) InitializeOfflineMode() {
26152615
db.DBStateManager.SetResyncFunc(TempResyncHandler)
26162616
db.DBStateManager.StartPolling(db.CancelContext)
26172617
}
2618+
2619+
// colletions returns the DatabaseCollection objects matching the following collection names.
2620+
func (db *DatabaseContext) collections(names base.CollectionNames) (DatabaseCollections, error) {
2621+
collections := make(DatabaseCollections, 0, len(names))
2622+
for scopeName, collectionsName := range names {
2623+
for _, collectionName := range collectionsName {
2624+
collection, err := db.GetDatabaseCollection(scopeName, collectionName)
2625+
if err != nil {
2626+
return nil, base.RedactErrorf("failed to find ID for collection %s.%s", base.MD(scopeName).Redact(), base.MD(collectionName).Redact())
2627+
}
2628+
collections = append(collections, collection)
2629+
}
2630+
}
2631+
return collections, nil
2632+
}

docs/api/components/schemas.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,6 +2014,7 @@ Resync-status:
20142014
type: integer
20152015
docs_errored:
20162016
description: The number of documents which have errored running resync.
2017+
type: integer
20172018
collections_processing:
20182019
description: The collections that the resync operation is running on.
20192020
allOf:

0 commit comments

Comments
 (0)