@cryptotaxi247 / kubo / commits / 24f0fa0fd

delegate teardown

this is silly but whatever License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>

Brian Tiger Chow committed Nov 17, 2014 at 21:12 UTC 24f0fa0fdea30a7005963d51ba46c5accea976db
1 file changed +8 -6
core/core.go
+8 -6
@@ -108,10 +108,10 @@ func NewIpfsNode(cfg *config.Config, online bool) (n *IpfsNode, err error) {
108 // derive this from a higher context.
109 ctx := context.TODO()
110 n = &IpfsNode{
111 - onlineMode: online,
112 - Config: cfg,
113 - ContextCloser: ctxc.NewContextCloser(ctx, nil),
111 + onlineMode: online,
112 + Config: cfg,
113 }
114 + n.ContextCloser = ctxc.NewContextCloser(context.TODO(), n.teardown)
115
116 // setup datastore.
117 if n.Datastore, err = makeDatastore(cfg.Datastore); err != nil {
@@ -191,9 +191,11 @@ func NewIpfsNode(cfg *config.Config, online bool) (n *IpfsNode, err error) {
191 return n, nil
192 }
193
194 -func (n *IpfsNode) Close() {
195 - n.ContextCloser.Close()
196 - n.Datastore.Close()
194 +func (n *IpfsNode) teardown() error {
195 + if err := n.Datastore.Close(); err != nil {
196 + return err
197 + }
198 + return nil
199 }
200
201 func (n *IpfsNode) OnlineMode() bool {