From c158f8a58c5b9cf9cd8f320d239f49c44668eab9 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 15 Nov 2024 19:25:53 -0600 Subject: [PATCH] Update() was broken --- packages.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages.go b/packages.go index fd21396..0dead0a 100644 --- a/packages.go +++ b/packages.go @@ -89,8 +89,8 @@ func (r *Packages) Append(newP *Package) bool { } // Update version and timestamp. -// returns (ok, changed) -func (r *Packages) Update(newP *Package) (bool, bool) { +// returns ok (ok == true if not found) +func (r *Packages) Update(newP *Package) bool { lock.Lock() defer lock.Unlock() @@ -102,7 +102,7 @@ func (r *Packages) Update(newP *Package) (bool, bool) { } if found == nil { // r.Append(newP) // update here? - return false, true + return true } var changed bool = false @@ -113,9 +113,7 @@ func (r *Packages) Update(newP *Package) (bool, bool) { now := time.Now() found.Laststamp = timestamppb.New(now) - - r.Packages = append(r.Packages, newP) - return true, changed + return changed } // returns time.Duration since last Update()