feat(BRIDGE-207): failure to download or verify an update now fails silently.

This commit is contained in:
Xavier Michelon
2024-09-24 12:54:04 +02:00
parent ebe54ca92e
commit e8a95e26f6
2 changed files with 13 additions and 1 deletions

View File

@ -21,6 +21,7 @@ import (
"context" "context"
"errors" "errors"
"github.com/ProtonMail/gluon/reporter"
"github.com/ProtonMail/proton-bridge/v3/internal/events" "github.com/ProtonMail/proton-bridge/v3/internal/events"
"github.com/ProtonMail/proton-bridge/v3/internal/safe" "github.com/ProtonMail/proton-bridge/v3/internal/safe"
"github.com/ProtonMail/proton-bridge/v3/internal/updater" "github.com/ProtonMail/proton-bridge/v3/internal/updater"
@ -115,6 +116,17 @@ func (bridge *Bridge) installUpdate(ctx context.Context, job installJob) {
err := bridge.updater.InstallUpdate(ctx, bridge.api, job.version) err := bridge.updater.InstallUpdate(ctx, bridge.api, job.version)
switch { switch {
case errors.Is(err, updater.ErrDownloadVerify):
// BRIDGE-207: if download or verification fails, we do not want to trigger a manual update. We report in the log and to Sentry
// and we fail silently.
log.WithError(err).Error("The update could not be installed, but we will fail silently")
if reporterErr := bridge.reporter.ReportMessageWithContext(
"Cannot download or verify update",
reporter.Context{"error": err},
); reporterErr != nil {
log.WithError(reporterErr).Error("Failed to report update error")
}
case errors.Is(err, updater.ErrUpdateAlreadyInstalled): case errors.Is(err, updater.ErrUpdateAlreadyInstalled):
log.Info("The update was already installed") log.Info("The update was already installed")

View File

@ -101,7 +101,7 @@ func (u *Updater) InstallUpdate(ctx context.Context, downloader Downloader, upda
update.Package+".sig", update.Package+".sig",
) )
if err != nil { if err != nil {
return ErrDownloadVerify return fmt.Errorf("%w: %w", ErrDownloadVerify, err)
} }
if err := u.installer.InstallUpdate(update.Version, bytes.NewReader(b)); err != nil { if err := u.installer.InstallUpdate(update.Version, bytes.NewReader(b)); err != nil {