diff --git a/cache/diff.go b/cache/diff.go index 96a8cc9..7bb69bd 100644 --- a/cache/diff.go +++ b/cache/diff.go @@ -42,6 +42,17 @@ func (c *DiffCache) Close() { } } +func (c *DiffCache) Flush() { + if c.Coords != nil { + c.Coords.Flush() + c.Coords = nil + } + if c.Ways != nil { + c.Ways.Flush() + c.Ways = nil + } +} + func (c *DiffCache) Open() error { var err error c.Coords, err = newCoordsRefIndex(filepath.Join(c.Dir, "coords_index")) @@ -213,6 +224,14 @@ func (index *bunchRefCache) getBunchId(id int64) int64 { return id / 64 } +func (index *bunchRefCache) Flush() { + if index.linearImport { + // disable linear import flushes buffer + index.SetLinearImport(false) + index.SetLinearImport(true) + } +} + func (index *bunchRefCache) Close() { if index.linearImport { // disable linear import first to flush buffer