Skip to content

Commit f1971d0

Browse files
authored
Merge pull request #112 from ipfs/fix/remove-closer-type-assertions
remove closer type assertions
2 parents c457b84 + 1813f01 commit f1971d0

File tree

4 files changed

+6
-22
lines changed

4 files changed

+6
-22
lines changed

basic_ds.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package datastore
22

33
import (
4-
"io"
54
"log"
65

76
dsq "github.com/ipfs/go-datastore/query"
@@ -244,10 +243,7 @@ func (d *LogBatch) Commit() (err error) {
244243

245244
func (d *LogDatastore) Close() error {
246245
log.Printf("%s: Close\n", d.Name)
247-
if cds, ok := d.child.(io.Closer); ok {
248-
return cds.Close()
249-
}
250-
return nil
246+
return d.child.Close()
251247
}
252248

253249
func (d *LogDatastore) Check() error {

keytransform/keytransform.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package keytransform
22

33
import (
4-
"io"
5-
64
ds "github.com/ipfs/go-datastore"
75
dsq "github.com/ipfs/go-datastore/query"
86
)
@@ -84,10 +82,7 @@ func (d *ktds) Query(q dsq.Query) (dsq.Results, error) {
8482
}
8583

8684
func (d *ktds) Close() error {
87-
if c, ok := d.child.(io.Closer); ok {
88-
return c.Close()
89-
}
90-
return nil
85+
return d.child.Close()
9186
}
9287

9388
// DiskUsage implements the PersistentDatastore interface.

mount/mount.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package mount
55
import (
66
"errors"
77
"fmt"
8-
"io"
98
"sort"
109
"strings"
1110
"sync"
@@ -195,11 +194,9 @@ func (d *Datastore) IsThreadSafe() {}
195194

196195
func (d *Datastore) Close() error {
197196
for _, d := range d.mounts {
198-
if c, ok := d.Datastore.(io.Closer); ok {
199-
err := c.Close()
200-
if err != nil {
201-
return err
202-
}
197+
err := d.Datastore.Close()
198+
if err != nil {
199+
return err
203200
}
204201
}
205202
return nil

sync/sync.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package sync
22

33
import (
4-
"io"
54
"sync"
65

76
ds "github.com/ipfs/go-datastore"
@@ -93,10 +92,7 @@ func (d *MutexDatastore) Batch() (ds.Batch, error) {
9392
func (d *MutexDatastore) Close() error {
9493
d.RWMutex.Lock()
9594
defer d.RWMutex.Unlock()
96-
if c, ok := d.child.(io.Closer); ok {
97-
return c.Close()
98-
}
99-
return nil
95+
return d.child.Close()
10096
}
10197

10298
// DiskUsage implements the PersistentDatastore interface.

0 commit comments

Comments
 (0)