add Flush to diff cache

master
Oliver Tonnhofer 2013-11-19 15:07:40 +01:00
parent b86ecff037
commit 1309a2f478
1 changed files with 19 additions and 0 deletions

19
cache/diff.go vendored
View File

@ -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