fix(GODT-3094): Clean up old update files on bridge startup.

This commit is contained in:
Romain LE JEUNE
2023-11-02 10:43:55 +01:00
parent 1ac4e70115
commit 6cb233473a
6 changed files with 24 additions and 3 deletions

View File

@ -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