Skip to content

Commit cbf9f1c

Browse files
author
Hongchao Deng
committed
close file in Destroy()
1 parent 0d5f4f0 commit cbf9f1c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

db/backend.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ func (b *backend) Put(rev int, path Path, data []byte) {
8989
}
9090

9191
// one-level listing
92-
func (b *backend) Ls(pathname string) []Path {
93-
result := make([]Path, 0)
92+
func (b *backend) Ls(pathname string) (paths []Path) {
93+
paths = make([]Path, 0)
9494
pivot := newPathForLs(pathname)
9595

9696
b.bt.AscendGreaterOrEqual(pivot, func(treeItem btree.Item) bool {
@@ -99,8 +99,8 @@ func (b *backend) Ls(pathname string) []Path {
9999
p.level != pivot.level {
100100
return false
101101
}
102-
result = append(result, *p)
102+
paths = append(paths, *p)
103103
return true
104104
})
105-
return result
105+
return
106106
}

db/log/log.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ func Create() (*Log, error) {
2020
}
2121

2222
func (l *Log) Destroy() error {
23+
if err := l.f.Close(); err != nil {
24+
return err
25+
}
2326
return os.Remove(l.f.Name())
2427
}
2528

0 commit comments

Comments
 (0)