From b0db1cdf7dcafc9cd000140780005b25f53d525d Mon Sep 17 00:00:00 2001 From: g026r Date: Fri, 18 Oct 2024 19:09:31 -0400 Subject: [PATCH] fix: the older or longer playtime is the one kept (#40) --- pkg/io/io.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/io/io.go b/pkg/io/io.go index 8c37569..a5f20a6 100644 --- a/pkg/io/io.go +++ b/pkg/io/io.go @@ -188,6 +188,11 @@ func LoadPlaytimes(root fs.FS) (map[uint32]models.PlayTime, error) { if _, err := v.ReadFrom(f); err != nil { return nil, err } + if p, ok := playtimes[sig]; ok && (p.Played > v.Played || p.Added < v.Added) { + // If you have duplicate playtimes, a side effect of adding a game with the same signature, keep the older or more played + // TODO: Can we find a way to allow duplicate signatures? + continue + } playtimes[sig] = v }