forked from Silverfish/proton-bridge
fix(BRIDGE-69): explicitly handle semver panic for last bridge version from vault
This commit is contained in:
@ -18,11 +18,13 @@
|
|||||||
package vault
|
package vault
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Masterminds/semver/v3"
|
"github.com/Masterminds/semver/v3"
|
||||||
|
"github.com/ProtonMail/proton-bridge/v3/internal/constants"
|
||||||
"github.com/ProtonMail/proton-bridge/v3/internal/updater"
|
"github.com/ProtonMail/proton-bridge/v3/internal/updater"
|
||||||
"github.com/ProtonMail/proton-bridge/v3/internal/useragent"
|
"github.com/ProtonMail/proton-bridge/v3/internal/useragent"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -200,7 +202,14 @@ func (vault *Vault) SetTelemetryDisabled(telemetryDisabled bool) error {
|
|||||||
|
|
||||||
// GetLastVersion returns the last version of the bridge that was run.
|
// GetLastVersion returns the last version of the bridge that was run.
|
||||||
func (vault *Vault) GetLastVersion() *semver.Version {
|
func (vault *Vault) GetLastVersion() *semver.Version {
|
||||||
return semver.MustParse(vault.getSafe().Settings.LastVersion)
|
lastVersion := vault.getSafe().Settings.LastVersion
|
||||||
|
version, err := semver.NewVersion(lastVersion)
|
||||||
|
if err != nil {
|
||||||
|
logrus.WithError(err).Error(fmt.Sprintf("Error encountered when trying to get last version from vault: %s", lastVersion))
|
||||||
|
version, _ = semver.NewVersion(constants.Version)
|
||||||
|
}
|
||||||
|
|
||||||
|
return version
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLastVersion sets the last version of the bridge that was run.
|
// SetLastVersion sets the last version of the bridge that was run.
|
||||||
|
|||||||
Reference in New Issue
Block a user