From 550b522618a76952095c7afd169bded6c79b4b02 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 3 Jan 2014 16:07:10 -0800 Subject: [PATCH] client: fix crashes when used by the Android app There is no config file on Android. Fixes camlistore.org/issue/287 Change-Id: If4bee897adee528f9ba58fb3093c327583e00ec4 --- pkg/client/config.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/client/config.go b/pkg/client/config.go index 2bb605b32..ab7922e9c 100644 --- a/pkg/client/config.go +++ b/pkg/client/config.go @@ -202,7 +202,7 @@ func (c *Client) SetupAuth() error { } configOnce.Do(parseConfig) var err error - if config.auth == "" { + if config == nil || config.auth == "" { c.authMode, err = auth.FromEnv() } else { c.authMode, err = auth.FromConfig(config.auth) @@ -230,6 +230,9 @@ func (c *Client) SecretRingFile() string { return e } configOnce.Do(parseConfig) + if config == nil || config.identitySecretRing == "" { + return osutil.IdentitySecretRing() + } return config.identitySecretRing } @@ -301,7 +304,7 @@ func (c *Client) initTrustedCerts() { } c.trustedCerts = []string{} configOnce.Do(parseConfig) - if config.trustedCerts == nil { + if config == nil || config.trustedCerts == nil { return } for _, trustedCert := range config.trustedCerts { @@ -326,7 +329,7 @@ func (c *Client) initIgnoredFiles() { } c.ignoredFiles = []string{} configOnce.Do(parseConfig) - if config.ignoredFiles == nil { + if config == nil || config.ignoredFiles == nil { return } c.ignoredFiles = config.ignoredFiles