From 207dff1b9ff2e0cb20907a1c9d65d12f299d14b3 Mon Sep 17 00:00:00 2001 From: Jarek Kowalski Date: Sun, 10 Sep 2017 12:22:28 -0700 Subject: [PATCH] also close current pack when time-based flushing happens --- repo/pack_manager.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/repo/pack_manager.go b/repo/pack_manager.go index 6a13f4324..488fba585 100644 --- a/repo/pack_manager.go +++ b/repo/pack_manager.go @@ -18,7 +18,7 @@ "github.com/kopia/kopia/blob" ) -const flushPackIndexTimeout = 10 * time.Minute +const flushPackIndexTimeout = 10 * time.Second const packObjectPrefix = "P" type packInfo struct { @@ -133,7 +133,12 @@ func (p *packManager) AddToPack(packGroup string, blockID string, data []byte) ( } if time.Now().After(p.flushPackIndexesAfter) { - p.flushPackIndexesLocked() + if err := p.finishCurrentPackLocked(); err != nil { + return NullObjectID, err + } + if err := p.flushPackIndexesLocked(); err != nil { + return NullObjectID, err + } } p.blockToIndex[blockID] = g.currentPackIndex