From b3b282e2c22c11cb53e4cf29f6b79c627e9f9ebd Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Wed, 6 Nov 2024 18:46:37 -0600 Subject: [PATCH] Fix issues with older revisions --- snapd-seed-glue/process.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/snapd-seed-glue/process.go b/snapd-seed-glue/process.go index 9f50b40..fecd2ab 100644 --- a/snapd-seed-glue/process.go +++ b/snapd-seed-glue/process.go @@ -15,6 +15,7 @@ package main import ( "fmt" "os" + "math" "path/filepath" "strconv" "strings" @@ -103,10 +104,18 @@ func collectSnapDependencies(snapName, channel, fallbackChannel, snapsDir, asser } info := result.Info + + // If the snap we fetched has a lower revision than the snap installed, use that + newRevision := 0 + if info.Revision.N != 0 && oldSnap != nil && oldSnap.Revision.N != 0 { + newRevision = int(math.Max(float64(info.Revision.N), float64(oldSnap.Revision.N))) + } else { + newRevision = info.Revision.N + } newSnap := &store.CurrentSnap{ InstanceName: snapName, SnapID: info.SnapID, - Revision: snap.Revision{N: info.Revision.N}, + Revision: snap.Revision{N: newRevision}, TrackingChannel: workingChannel, } snapInCurrentSnaps, oldRevision := isSnapInCurrentSnaps(snapName)