mirror of https://github.com/perkeep/perkeep.git
client: tolerate missing config file
Change-Id: I43fd2439b3eddb3d883d0db6cc6f23fe535aeb28
This commit is contained in:
parent
ec8f01c467
commit
16a7ecf55a
|
@ -57,9 +57,14 @@ func ConfigFilePath() string {
|
|||
|
||||
var configOnce sync.Once
|
||||
var config = make(map[string]interface{})
|
||||
var parseConfigErr error
|
||||
|
||||
func parseConfig() {
|
||||
configPath := ConfigFilePath()
|
||||
if _, err := os.Stat(configPath); os.IsNotExist(err) {
|
||||
parseConfigErr = os.ErrNotExist
|
||||
return
|
||||
}
|
||||
|
||||
var err error
|
||||
if config, err = jsonconfig.ReadFile(configPath); err != nil {
|
||||
|
@ -98,7 +103,6 @@ func serverOrDie() string {
|
|||
}
|
||||
|
||||
func (c *Client) SetupAuth() error {
|
||||
configOnce.Do(parseConfig)
|
||||
if flagServer != nil && *flagServer != "" {
|
||||
// If using an explicit blobserver, don't use auth
|
||||
// configured from the config file, so we don't send
|
||||
|
@ -110,6 +114,7 @@ func (c *Client) SetupAuth() error {
|
|||
}
|
||||
return err
|
||||
}
|
||||
configOnce.Do(parseConfig)
|
||||
return c.SetupAuthFromConfig(config)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue