mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-18 16:26:38 +00:00
Resolve issues
This commit is contained in:
@@ -61,11 +61,6 @@ func NewUpdateManager(statusRecorder *peer.Status) *UpdateManager {
|
|||||||
return manager
|
return manager
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UpdateManager) WithCustomVersionUpdate(versionUpdate UpdateInterface) *UpdateManager {
|
|
||||||
u.update = versionUpdate
|
|
||||||
return u
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *UpdateManager) Start(ctx context.Context) {
|
func (u *UpdateManager) Start(ctx context.Context) {
|
||||||
if u.cancel != nil {
|
if u.cancel != nil {
|
||||||
log.Errorf("UpdateManager already started")
|
log.Errorf("UpdateManager already started")
|
||||||
@@ -124,10 +119,12 @@ func (u *UpdateManager) Stop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
u.cancel()
|
u.cancel()
|
||||||
|
u.expectedVersionMutex.Lock()
|
||||||
if u.update != nil {
|
if u.update != nil {
|
||||||
u.update.StopWatch()
|
u.update.StopWatch()
|
||||||
u.update = nil
|
u.update = nil
|
||||||
}
|
}
|
||||||
|
u.expectedVersionMutex.Unlock()
|
||||||
|
|
||||||
u.wg.Wait()
|
u.wg.Wait()
|
||||||
}
|
}
|
||||||
@@ -151,6 +148,9 @@ func (u *UpdateManager) handleUpdate(ctx context.Context) {
|
|||||||
var updateVersion *v.Version
|
var updateVersion *v.Version
|
||||||
|
|
||||||
u.expectedVersionMutex.Lock()
|
u.expectedVersionMutex.Lock()
|
||||||
|
if u.update == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
expectedVersion := u.expectedVersion
|
expectedVersion := u.expectedVersion
|
||||||
useLatest := u.updateToLatestVersion
|
useLatest := u.updateToLatestVersion
|
||||||
curLatestVersion := u.update.LatestVersion()
|
curLatestVersion := u.update.LatestVersion()
|
||||||
@@ -176,7 +176,7 @@ func (u *UpdateManager) handleUpdate(ctx context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(time.Minute))
|
ctx, cancel := context.WithTimeout(ctx, time.Minute)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
u.lastTrigger = time.Now()
|
u.lastTrigger = time.Now()
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (u *UpdateManager) WithCustomVersionUpdate(versionUpdate UpdateInterface) *UpdateManager {
|
||||||
|
u.update = versionUpdate
|
||||||
|
return u
|
||||||
|
}
|
||||||
|
|
||||||
type versionUpdateMock struct {
|
type versionUpdateMock struct {
|
||||||
latestVersion *v.Version
|
latestVersion *v.Version
|
||||||
onUpdate func()
|
onUpdate func()
|
||||||
|
|||||||
10
client/internal/updatemanager/update_js.go
Normal file
10
client/internal/updatemanager/update_js.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
//go:build js
|
||||||
|
|
||||||
|
package updatemanager
|
||||||
|
|
||||||
|
import "context"
|
||||||
|
|
||||||
|
func triggerUpdate(ctx context.Context, targetVersion string) error {
|
||||||
|
// TODO: Implement
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user