From 579a05e4dfa7769042941ce8cf235661d8300357 Mon Sep 17 00:00:00 2001 From: Lou Knauer Date: Mon, 22 Nov 2021 17:50:15 +0100 Subject: [PATCH] Fix bug in calculation of what is archived --- memstore.go | 3 ++- memstore_test.go | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/memstore.go b/memstore.go index 778b3c4..b708747 100644 --- a/memstore.go +++ b/memstore.go @@ -45,6 +45,7 @@ func newBuffer(ts, freq int64) *buffer { b.start = ts b.prev = nil b.next = nil + b.archived = false return b } @@ -167,7 +168,7 @@ func (b *buffer) iterFromTo(from, to int64, callback func(b *buffer) error) erro } end := b.start + int64(len(b.data))*b.frequency - if from <= b.start && end <= to { + if from <= end && b.start <= to { return callback(b) } diff --git a/memstore_test.go b/memstore_test.go index 8967103..8809399 100644 --- a/memstore_test.go +++ b/memstore_test.go @@ -295,6 +295,8 @@ func TestMemoryStoreArchive(t *testing.T) { } } + // store1.DebugDump(bufio.NewWriter(os.Stdout)) + archiveRoot := t.TempDir() _, err := store1.ToCheckpoint(archiveRoot, 100, 100+int64(count/2)) if err != nil {