forked from Silverfish/proton-bridge
fix(GODT-3094): Clean up old update files on bridge startup.
This commit is contained in:
@ -26,6 +26,7 @@ import (
|
||||
|
||||
"github.com/Masterminds/semver/v3"
|
||||
"github.com/ProtonMail/gopenpgp/v2/crypto"
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/versioner"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -46,15 +47,17 @@ type Installer interface {
|
||||
}
|
||||
|
||||
type Updater struct {
|
||||
versioner *versioner.Versioner
|
||||
installer Installer
|
||||
verifier *crypto.KeyRing
|
||||
product string
|
||||
platform string
|
||||
}
|
||||
|
||||
func NewUpdater(installer Installer, verifier *crypto.KeyRing, product, platform string) *Updater {
|
||||
func NewUpdater(ver *versioner.Versioner, verifier *crypto.KeyRing, product, platform string) *Updater {
|
||||
return &Updater{
|
||||
installer: installer,
|
||||
versioner: ver,
|
||||
installer: NewInstaller(ver),
|
||||
verifier: verifier,
|
||||
product: product,
|
||||
platform: platform,
|
||||
@ -109,6 +112,10 @@ func (u *Updater) InstallUpdate(ctx context.Context, downloader Downloader, upda
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *Updater) RemoveOldUpdates() error {
|
||||
return u.versioner.RemoveOldVersions()
|
||||
}
|
||||
|
||||
// getVersionFileURL returns the URL of the version file.
|
||||
// For example:
|
||||
// - https://protonmail.com/download/bridge/version_linux.json
|
||||
|
||||
Reference in New Issue
Block a user