feat: only persist cookies on app teardown

This commit is contained in:
James Houlahan
2020-12-16 15:45:37 +01:00
parent 7b4204591c
commit d3b0871cf1
7 changed files with 119 additions and 153 deletions

View File

@ -68,6 +68,7 @@ type Base struct {
Listener listener.Listener
Creds *credentials.Store
CM *pmapi.ClientManager
CookieJar *cookies.Jar
Updater *updater.Updater
Versioner *versioner.Versioner
TLS *tls.TLS
@ -209,6 +210,7 @@ func New( // nolint[funlen]
Listener: listener,
Creds: creds,
CM: cm,
CookieJar: jar,
Updater: updater,
Versioner: versioner,
TLS: tls,

View File

@ -111,6 +111,9 @@ func run(b *base.Base, c *cli.Context) error { // nolint[funlen]
// We want to remove old versions if the app exits successfully.
b.AddTeardownAction(b.Versioner.RemoveOldVersions)
// We want cookies to be saved to disk so they are loaded the next time.
b.AddTeardownAction(b.CookieJar.PersistCookies)
f := frontend.New(
constants.Version,
constants.BuildVersion,

View File

@ -57,6 +57,9 @@ func run(b *base.Base, c *cli.Context) error {
// We want to remove old versions if the app exits successfully.
b.AddTeardownAction(b.Versioner.RemoveOldVersions)
// We want cookies to be saved to disk so they are loaded the next time.
b.AddTeardownAction(b.CookieJar.PersistCookies)
f := frontend.NewImportExport(
constants.Version,
constants.BuildVersion,