GODT-1813: Cleanup old go-imap cache files

This commit is contained in:
Leander Beernaert
2022-10-19 14:07:45 +02:00
committed by James Houlahan
parent e0ff30e9a8
commit d47b5b99c5
3 changed files with 42 additions and 0 deletions

View File

@ -41,6 +41,9 @@ import (
const vaultSecretName = "bridge-vault-key"
// deleteOldGoIMAPFiles Set with `-ldflags -X app.deleteOldGoIMAPFiles=true` to enable cleanup of old imap cache data.
var deleteOldGoIMAPFiles bool //nolint:gochecknoglobals
// withBridge creates creates and tears down the bridge.
func withBridge( //nolint:funlen
c *cli.Context,
@ -61,6 +64,13 @@ func withBridge( //nolint:funlen
dialer.NewTLSPinChecker(dialer.TrustedAPIPins),
)
// Delete old go-imap cache files
if deleteOldGoIMAPFiles {
if err := locations.CleanGoIMAPCache(); err != nil {
logrus.WithError(err).Error("Failed to remove old go-imap cache")
}
}
// Create a proxy dialer which switches to a proxy if the request fails.
proxyDialer := dialer.NewProxyTLSDialer(pinningDialer, constants.APIHost)