client: fix crashes when used by the Android app

There is no config file on Android.

Fixes camlistore.org/issue/287

Change-Id: If4bee897adee528f9ba58fb3093c327583e00ec4
This commit is contained in:
Brad Fitzpatrick 2014-01-03 16:07:10 -08:00
parent bc37ea6ead
commit 550b522618
1 changed files with 6 additions and 3 deletions

View File

@ -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