internal/sync2: fix file handle leak (#1124)

This commit is contained in:
Egon Elbre 2019-01-24 22:48:54 +02:00 committed by GitHub
parent f5b1e77cf2
commit 78b0414e6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 3 deletions

View File

@ -78,7 +78,7 @@ func (file offsetFile) WriteAt(data []byte, at int64) (amount int, err error) {
func (file offsetFile) Close() error {
if atomic.AddInt64(file.open, -1) == 0 {
return errs.Combine(
file.Close(),
file.file.Close(),
os.Remove(file.file.Name()),
)
}

View File

@ -5,7 +5,6 @@ package kademlia
import (
"bytes"
"fmt"
"sync"
"testing"
"time"
@ -326,7 +325,6 @@ func TestDetermineFurthestIDWithinK(t *testing.T) {
nodes, err := rt.nodeBucketDB.List(nil, 0)
assert.NoError(t, err)
furthest := rt.determineFurthestIDWithinK(teststorj.NodeIDsFromBytes(nodes.ByteSlices()...))
fmt.Println(furthest.Bytes())
assert.Equal(t, c.expectedFurthest, furthest[:2])
})
}