diff --git a/internal/usage/heat_disk.go b/internal/usage/heat_disk.go index 99921ac0e..b5429f3db 100644 --- a/internal/usage/heat_disk.go +++ b/internal/usage/heat_disk.go @@ -80,9 +80,16 @@ func heatSettledKey(d heatDiskRef, cut, since time.Time, f Filter, identities ma if d.root == "" { return "", false } + // the filter's zone by its name: %#v writes its pointer, another in + // each run + zone := "" + if f.Zone != nil { + zone = f.Zone.String() + } + f.Zone = nil h := sha256.New() - fmt.Fprintf(h, "heat-v1\x00%s\x00%s\x00%s\x00%d\x00%d\x00%s\x00%#v\x00%d:%d:%d\x00", - requestDiskBinary(), d.root, d.meta, cut.UnixNano(), since.UnixNano(), cut.Location(), f, before.n, before.at, before.tokens) + fmt.Fprintf(h, "heat-v1\x00%s\x00%s\x00%s\x00%d\x00%d\x00%s\x00%#v\x00%s\x00%d:%d:%d\x00", + requestDiskBinary(), d.root, d.meta, cut.UnixNano(), since.UnixNano(), cut.Location(), f, zone, before.n, before.at, before.tokens) hashCodexIdentities(h, identities) var b []byte rows := lentRows() diff --git a/internal/usage/heatmap_test.go b/internal/usage/heatmap_test.go index bb90c75bd..9b96b7736 100644 --- a/internal/usage/heatmap_test.go +++ b/internal/usage/heatmap_test.go @@ -382,3 +382,25 @@ func TestHeatmapSettledDaysFromDisk(t *testing.T) { t.Fatalf("after a settled file changed %+v, cold %+v", changed, cold) } } + +// The settled days' key names a filter's zone by its name: written with +// %#v it named the zone's pointer, another in each run, and every start +// paired the whole history again for the heatmap. +func TestHeatSettledKeyNamesTheZone(t *testing.T) { + cut := time.Date(2026, 9, 28, 0, 0, 0, 0, time.UTC) + d := heatDiskRef{root: "r", meta: "m"} + key := func(f Filter) string { + k, ok := heatSettledKey(d, cut, time.Time{}, f, nil, [3][]*rowChunk{}, heatSum{}) + if !ok { + t.Fatal("not named") + } + return k + } + a, b := key(Filter{Zone: time.FixedZone("Z", 3600)}), key(Filter{Zone: time.FixedZone("Z", 3600)}) + if a != b { + t.Fatalf("one zone, two keys: %s, %s", a, b) + } + if key(Filter{}) == a || key(Filter{Zone: time.FixedZone("Y", 7200)}) == a { + t.Fatal("another zone, the same key") + } +}