Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove closer type assertions #112

Merged
merged 1 commit into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions basic_ds.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package datastore

import (
"io"
"log"

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

func (d *LogDatastore) Close() error {
log.Printf("%s: Close\n", d.Name)
if cds, ok := d.child.(io.Closer); ok {
return cds.Close()
}
return nil
return d.child.Close()
}

func (d *LogDatastore) Check() error {
Expand Down
7 changes: 1 addition & 6 deletions keytransform/keytransform.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package keytransform

import (
"io"

ds "github.com/ipfs/go-datastore"
dsq "github.com/ipfs/go-datastore/query"
)
Expand Down Expand Up @@ -84,10 +82,7 @@ func (d *ktds) Query(q dsq.Query) (dsq.Results, error) {
}

func (d *ktds) Close() error {
if c, ok := d.child.(io.Closer); ok {
return c.Close()
}
return nil
return d.child.Close()
}

// DiskUsage implements the PersistentDatastore interface.
Expand Down
9 changes: 3 additions & 6 deletions mount/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package mount
import (
"errors"
"fmt"
"io"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -195,11 +194,9 @@ func (d *Datastore) IsThreadSafe() {}

func (d *Datastore) Close() error {
for _, d := range d.mounts {
if c, ok := d.Datastore.(io.Closer); ok {
err := c.Close()
if err != nil {
return err
}
err := d.Datastore.Close()
if err != nil {
return err
}
}
return nil
Expand Down
6 changes: 1 addition & 5 deletions sync/sync.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package sync

import (
"io"
"sync"

ds "github.com/ipfs/go-datastore"
Expand Down Expand Up @@ -93,10 +92,7 @@ func (d *MutexDatastore) Batch() (ds.Batch, error) {
func (d *MutexDatastore) Close() error {
d.RWMutex.Lock()
defer d.RWMutex.Unlock()
if c, ok := d.child.(io.Closer); ok {
return c.Close()
}
return nil
return d.child.Close()
}

// DiskUsage implements the PersistentDatastore interface.
Expand Down