Commit 68bfc85 1 parent 73b21dd commit 68bfc85 Copy full SHA for 68bfc85
File tree 1 file changed +22
-7
lines changed
1 file changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -82,19 +82,24 @@ func (i *Importer) writeNode(node *Node) error {
82
82
i .batchSize ++
83
83
if i .batchSize >= maxBatchSize {
84
84
// Wait for previous batch.
85
- var err error
86
85
if i .inflightCommit != nil {
87
- err = <- i .inflightCommit
86
+ err := <- i .inflightCommit
87
+ if err != nil {
88
+ return err
89
+ }
90
+
88
91
i .inflightCommit = nil
89
92
}
90
- if err != nil {
91
- return err
92
- }
93
+
93
94
result := make (chan error )
94
95
i .inflightCommit = result
95
96
go func (batch store.Batch ) {
96
- defer batch .Close ()
97
- result <- batch .Write ()
97
+ if err := batch .WriteSync (); err != nil {
98
+ result <- err
99
+ return
100
+ }
101
+
102
+ result <- batch .Close ()
98
103
}(i .batch )
99
104
i .batch = i .tree .ndb .db .NewBatch ()
100
105
i .batchSize = 0
@@ -223,6 +228,16 @@ func (i *Importer) Commit() error {
223
228
return err
224
229
}
225
230
231
+ // Wait for previous batch.
232
+ if i .inflightCommit != nil {
233
+ err := <- i .inflightCommit
234
+ if err != nil {
235
+ return err
236
+ }
237
+
238
+ i .inflightCommit = nil
239
+ }
240
+
226
241
err = i .batch .WriteSync ()
227
242
if err != nil {
228
243
return err
You can’t perform that action at this time.
0 commit comments