mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 23:56:56 +00:00
GODT-976 Exclude updates from clearing cache and clear cache, including updates, while switching early access off
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user