Merge branch 'feat/auto-upgrade' into auto-upgrade-mod

This commit is contained in:
M Essam Hamed
2025-10-08 19:35:20 +03:00
3 changed files with 21 additions and 6 deletions

View File

@@ -74,11 +74,6 @@ func NewUpdateManager(statusRecorder *peer.Status, stateManager *statemanager.Ma
return manager
}
func (u *UpdateManager) WithCustomVersionUpdate(versionUpdate UpdateInterface) *UpdateManager {
u.update = versionUpdate
return u
}
func (u *UpdateManager) StartWithTimeout(ctx context.Context, timeout time.Duration) {
if u.cancel != nil {
log.Errorf("UpdateManager already started")
@@ -180,10 +175,12 @@ func (u *UpdateManager) Stop() {
}
u.cancel()
u.expectedVersionMutex.Lock()
if u.update != nil {
u.update.StopWatch()
u.update = nil
}
u.expectedVersionMutex.Unlock()
u.wg.Wait()
}
@@ -219,6 +216,9 @@ func (u *UpdateManager) handleUpdate(ctx context.Context) {
var updateVersion *v.Version
u.expectedVersionMutex.Lock()
if u.update == nil {
return
}
expectedVersion := u.expectedVersion
useLatest := u.updateToLatestVersion
curLatestVersion := u.update.LatestVersion()
@@ -244,7 +244,7 @@ func (u *UpdateManager) handleUpdate(ctx context.Context) {
return
}
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(time.Minute))
ctx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
u.lastTrigger = time.Now()

View File

@@ -11,6 +11,11 @@ import (
"time"
)
func (u *UpdateManager) WithCustomVersionUpdate(versionUpdate UpdateInterface) *UpdateManager {
u.update = versionUpdate
return u
}
type versionUpdateMock struct {
latestVersion *v.Version
onUpdate func()

View File

@@ -0,0 +1,10 @@
//go:build js
package updatemanager
import "context"
func triggerUpdate(ctx context.Context, targetVersion string) error {
// TODO: Implement
return nil
}