diff --git a/cache/osm.go b/cache/osm.go index 620bafb..cd5797d 100644 --- a/cache/osm.go +++ b/cache/osm.go @@ -39,6 +39,10 @@ func (c *OSMCache) Close() { c.Relations.Close() c.Relations = nil } + if c.InsertedWays != nil { + c.InsertedWays.Close() + c.InsertedWays = nil + } } func NewOSMCache(dir string) *OSMCache { @@ -172,8 +176,12 @@ func idFromKeyBuf(buf []byte) int64 { } func (c *Cache) Close() { - c.db.Close() + if c.db != nil { + c.db.Close() + c.db = nil + } if c.cache != nil { c.cache.Close() + c.cache = nil } } diff --git a/goposm.go b/goposm.go index f565bed..773151e 100644 --- a/goposm.go +++ b/goposm.go @@ -227,9 +227,7 @@ func main() { // blocks till the Nodes.Iter() finishes nodeWriter.Close() - osmCache.Nodes.Close() - osmCache.Coords.Close() - osmCache.Coords.SetReadOnly(false) + osmCache.Close() err = db.End() if err != nil {