mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 04:36:43 +00:00
GODT-976 Exclude updates from clearing cache and clear cache, including updates, while switching early access off
This commit is contained in:
@ -17,8 +17,16 @@
|
||||
|
||||
package versioner
|
||||
|
||||
import "github.com/Masterminds/semver/v3"
|
||||
|
||||
// RemoveOldVersions removes all but the latest app version.
|
||||
func (v *Versioner) RemoveOldVersions() error {
|
||||
// darwin does not use the versioner; removal is a noop.
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemoveOtherVersions removes all but the specific provided app version.
|
||||
func (v *Versioner) RemoveOtherVersions(versionToKeep *semver.Version) error {
|
||||
// darwin does not use the versioner; removal is a noop.
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ package versioner
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/Masterminds/semver/v3"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@ -45,3 +46,22 @@ func (v *Versioner) RemoveOldVersions() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemoveOtherVersions removes all but the specific provided app version.
|
||||
func (v *Versioner) RemoveOtherVersions(versionToKeep *semver.Version) error {
|
||||
versions, err := v.ListVersions()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, version := range versions {
|
||||
if version.Equal(versionToKeep) {
|
||||
continue
|
||||
}
|
||||
if err := os.RemoveAll(version.path); err != nil {
|
||||
logrus.WithError(err).Error("Failed to remove old app version")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -55,6 +55,10 @@ func (v *Version) String() string {
|
||||
return fmt.Sprintf("%v", v.version)
|
||||
}
|
||||
|
||||
func (v *Version) Equal(version *semver.Version) bool {
|
||||
return v.version.Equal(version)
|
||||
}
|
||||
|
||||
// VerifyFiles verifies all files in the version directory.
|
||||
func (v *Version) VerifyFiles(kr *crypto.KeyRing) error {
|
||||
fileBytes, err := ioutil.ReadFile(filepath.Join(v.path, sumFile)) // nolint[gosec]
|
||||
|
||||
Reference in New Issue
Block a user