mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 04:36:43 +00:00
fix(GODT-2277): Fix keychains initialisation in vault-editor.
This commit is contained in:
@ -236,7 +236,7 @@ func run(c *cli.Context) error {
|
|||||||
|
|
||||||
return withSingleInstance(settings, locations.GetLockFile(), version, func() error {
|
return withSingleInstance(settings, locations.GetLockFile(), version, func() error {
|
||||||
// Look for available keychains
|
// Look for available keychains
|
||||||
return withKeychainList(func(keychains *keychain.List) error {
|
return WithKeychainList(func(keychains *keychain.List) error {
|
||||||
// Unlock the encrypted vault.
|
// Unlock the encrypted vault.
|
||||||
return WithVault(locations, keychains, crashHandler, func(v *vault.Vault, insecure, corrupt bool) error {
|
return WithVault(locations, keychains, crashHandler, func(v *vault.Vault, insecure, corrupt bool) error {
|
||||||
if !v.Migrated() {
|
if !v.Migrated() {
|
||||||
@ -484,8 +484,8 @@ func withCookieJar(vault *vault.Vault, fn func(http.CookieJar) error) error {
|
|||||||
return fn(persister)
|
return fn(persister)
|
||||||
}
|
}
|
||||||
|
|
||||||
// List usable keychains.
|
// WithKeychainList init the list of usable keychains.
|
||||||
func withKeychainList(fn func(*keychain.List) error) error {
|
func WithKeychainList(fn func(*keychain.List) error) error {
|
||||||
logrus.Debug("Creating keychain list")
|
logrus.Debug("Creating keychain list")
|
||||||
defer logrus.Debug("Keychain list stop")
|
defer logrus.Debug("Keychain list stop")
|
||||||
return fn(keychain.NewList())
|
return fn(keychain.NewList())
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import (
|
|||||||
"github.com/ProtonMail/proton-bridge/v3/internal/app"
|
"github.com/ProtonMail/proton-bridge/v3/internal/app"
|
||||||
"github.com/ProtonMail/proton-bridge/v3/internal/locations"
|
"github.com/ProtonMail/proton-bridge/v3/internal/locations"
|
||||||
"github.com/ProtonMail/proton-bridge/v3/internal/vault"
|
"github.com/ProtonMail/proton-bridge/v3/internal/vault"
|
||||||
|
"github.com/ProtonMail/proton-bridge/v3/pkg/keychain"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -50,12 +51,14 @@ func main() {
|
|||||||
|
|
||||||
func readAction(c *cli.Context) error {
|
func readAction(c *cli.Context) error {
|
||||||
return app.WithLocations(func(locations *locations.Locations) error {
|
return app.WithLocations(func(locations *locations.Locations) error {
|
||||||
return app.WithVault(locations, nil, async.NoopPanicHandler{}, func(vault *vault.Vault, insecure, corrupt bool) error {
|
return app.WithKeychainList(func(keychains *keychain.List) error {
|
||||||
if _, err := os.Stdout.Write(vault.ExportJSON()); err != nil {
|
return app.WithVault(locations, keychains, async.NoopPanicHandler{}, func(vault *vault.Vault, insecure, corrupt bool) error {
|
||||||
return fmt.Errorf("failed to write vault: %w", err)
|
if _, err := os.Stdout.Write(vault.ExportJSON()); err != nil {
|
||||||
}
|
return fmt.Errorf("failed to write vault: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user