fix(core) improve documentation and describe behavior of function
Brian Tiger Chow committed
Jan 17, 2015 at 02:56 UTC
15a6237ffc198a0e750f013ab9ad7ba7e6ec5caa
1 file changed
+6
-5
core/core.go
+6
-5
@@ -263,8 +263,11 @@ func (n *IpfsNode) StartOnlineServices(ctx context.Context) error {
263
return nil
264
}
265
266
-// teardown closes children
266
+// teardown closes owned children. If any errors occur, this function returns
267
+// the first error.
268
func (n *IpfsNode) teardown() error {
269
+ // owned objects are closed in this teardown to ensure that they're closed
270
+ // regardless of which constructor was used to add them to the node.
271
var closers []io.Closer
272
if n.Repo != nil {
273
closers = append(closers, n.Repo)
@@ -277,10 +280,8 @@ func (n *IpfsNode) teardown() error {
280
}
281
var errs []error
282
for _, closer := range closers {
280
- if closer != nil {
281
- if err := closer.Close(); err != nil {
282
- errs = append(errs, err)
283
- }
283
+ if err := closer.Close(); err != nil {
284
+ errs = append(errs, err)
285
}
286
}
287
if len(errs) > 0 {