forked from Silverfish/proton-bridge
feat(GODT-2385): Gluon cache fallback
Update Gluon to have access to the cache fallback reader. Provide fallback reader to handle old cache file format. Remove the old logic to erase all cache files on start as the fallback option renders this irrelevant.
This commit is contained in:
2
go.mod
2
go.mod
@ -5,7 +5,7 @@ go 1.18
|
||||
require (
|
||||
github.com/0xAX/notificator v0.0.0-20220220101646-ee9b8921e557
|
||||
github.com/Masterminds/semver/v3 v3.1.1
|
||||
github.com/ProtonMail/gluon v0.14.2-0.20230221144046-c8f22fc170e9
|
||||
github.com/ProtonMail/gluon v0.15.0
|
||||
github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a
|
||||
github.com/ProtonMail/go-proton-api v0.4.1-0.20230217130533-0af5d2f08497
|
||||
github.com/ProtonMail/go-rfc5322 v0.11.0
|
||||
|
||||
4
go.sum
4
go.sum
@ -28,8 +28,8 @@ github.com/ProtonMail/bcrypt v0.0.0-20211005172633-e235017c1baf h1:yc9daCCYUefEs
|
||||
github.com/ProtonMail/bcrypt v0.0.0-20211005172633-e235017c1baf/go.mod h1:o0ESU9p83twszAU8LBeJKFAAMX14tISa0yk4Oo5TOqo=
|
||||
github.com/ProtonMail/docker-credential-helpers v1.1.0 h1:+kvUIpwWcbtP3WFv5sSvkFn/XLzSqPOB5AAthuk9xPk=
|
||||
github.com/ProtonMail/docker-credential-helpers v1.1.0/go.mod h1:mK0aBveCxhnQ756AmaTfXMZDeULvheYVhF/MWMErN5g=
|
||||
github.com/ProtonMail/gluon v0.14.2-0.20230221144046-c8f22fc170e9 h1:938+11VjjzuIJ0YJfS16ZMPvWe8msmCY6is0llEv6TM=
|
||||
github.com/ProtonMail/gluon v0.14.2-0.20230221144046-c8f22fc170e9/go.mod h1:HYHr7hG7LPWI1S50M8NfHRb1kYi5B+Yu4/N/H+y+JUY=
|
||||
github.com/ProtonMail/gluon v0.15.0 h1:Hai69s25OFrubR3rSNsLtErZn+jtknGnZ3ATzlog7Ds=
|
||||
github.com/ProtonMail/gluon v0.15.0/go.mod h1:HYHr7hG7LPWI1S50M8NfHRb1kYi5B+Yu4/N/H+y+JUY=
|
||||
github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a h1:D+aZah+k14Gn6kmL7eKxoo/4Dr/lK3ChBcwce2+SQP4=
|
||||
github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a/go.mod h1:oTGdE7/DlWIr23G0IKW3OXK9wZ5Hw1GGiaJFccTvZi4=
|
||||
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
|
||||
|
||||
@ -226,18 +226,6 @@ func run(c *cli.Context) error {
|
||||
_ = reporter.ReportMessageWithContext("Vault is corrupt", map[string]interface{}{})
|
||||
}
|
||||
|
||||
// Force re-sync if last version <= 3.0.12 due to chances in the gluon cache format.
|
||||
if lastVersion := v.GetLastVersion(); lastVersion != nil {
|
||||
versionWithLZ4Cache := semver.MustParse("3.0.13")
|
||||
if lastVersion.LessThan(versionWithLZ4Cache) {
|
||||
if err := v.ForUser(1, func(user *vault.User) error {
|
||||
return user.ClearSyncStatus()
|
||||
}); err != nil {
|
||||
logrus.WithError(err).Error("Failed to force resync on user")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !v.Migrated() {
|
||||
// Migrate old settings into the vault.
|
||||
if err := migrateOldSettings(v); err != nil {
|
||||
|
||||
@ -31,6 +31,7 @@ import (
|
||||
"github.com/ProtonMail/gluon/imap"
|
||||
"github.com/ProtonMail/gluon/reporter"
|
||||
"github.com/ProtonMail/gluon/store"
|
||||
"github.com/ProtonMail/gluon/store/fallback_v0"
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/async"
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/constants"
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/events"
|
||||
@ -377,6 +378,7 @@ func (*storeBuilder) New(path, userID string, passphrase []byte) (store.Store, e
|
||||
return store.NewOnDiskStore(
|
||||
filepath.Join(path, userID),
|
||||
passphrase,
|
||||
store.WithFallback(fallback_v0.NewOnDiskStoreV0WithCompressor(&fallback_v0.GZipCompressor{})),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user