diff --git a/tracker/tracker.go b/tracker/tracker.go index 1176c29..f878348 100644 --- a/tracker/tracker.go +++ b/tracker/tracker.go @@ -25,6 +25,7 @@ package tracker import ( + "bytes" "encoding/csv" "fmt" "os" @@ -106,11 +107,12 @@ type TrackerImpl struct { type Iterator struct { trie.NodeIterator - tracker *TrackerImpl + tracker *TrackerImpl + prevPath []byte } func (tr *TrackerImpl) Tracked(it trie.NodeIterator) *Iterator { - ret := &Iterator{it, tr} + ret := &Iterator{it, tr, nil} tr.startChan <- ret return ret } @@ -128,7 +130,7 @@ func (tr *TrackerImpl) Save() error { for it := range tr.started { _, endPath := it.Bounds() rows = append(rows, []string{ - fmt.Sprintf("%x", it.Path()), + fmt.Sprintf("%x", it.prevPath), fmt.Sprintf("%x", endPath), }) } @@ -232,6 +234,7 @@ func (tr *TrackerImpl) CloseAndSave() error { // Next advances the iterator, notifying its owning tracker when it finishes. func (it *Iterator) Next(descend bool) bool { + it.prevPath = bytes.Clone(it.Path()) ret := it.NodeIterator.Next(descend) if !ret {