File tree 2 files changed +19
-4
lines changed
2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -258,8 +258,6 @@ func ResultsWithEntries(q Query, res []Entry) Results {
258
258
})
259
259
}
260
260
261
- }
262
-
263
261
func ResultsReplaceQuery (r Results , q Query ) Results {
264
262
switch r := r .(type ) {
265
263
case * results :
Original file line number Diff line number Diff line change @@ -61,11 +61,28 @@ func (d *MutexDatastore) Delete(key ds.Key) (err error) {
61
61
return d .child .Delete (key )
62
62
}
63
63
64
- // KeyList implements Datastore.KeyList
64
+ // Query implements Datastore.Query
65
65
func (d * MutexDatastore ) Query (q dsq.Query ) (dsq.Results , error ) {
66
66
d .RLock ()
67
67
defer d .RUnlock ()
68
- return d .child .Query (q )
68
+
69
+ // Apply the entire query while locked. Non-sync datastores may not
70
+ // allow concurrent queries.
71
+
72
+ results , err := d .child .Query (q )
73
+ if err != nil {
74
+ return nil , err
75
+ }
76
+
77
+ entries , err1 := results .Rest ()
78
+ err2 := results .Close ()
79
+ switch {
80
+ case err1 != nil :
81
+ return nil , err1
82
+ case err2 != nil :
83
+ return nil , err2
84
+ }
85
+ return dsq .ResultsWithEntries (q , entries ), nil
69
86
}
70
87
71
88
func (d * MutexDatastore ) Batch () (ds.Batch , error ) {
You can’t perform that action at this time.
0 commit comments