mirror of https://github.com/perkeep/perkeep.git
client: don't access UserClientConfigPath or osutil.Homedir unless necessary
Change-Id: I618941204eb561461aab960bde576963296cea87
This commit is contained in:
parent
6d30b8d274
commit
520191ecc5
|
@ -28,6 +28,7 @@ import (
|
||||||
|
|
||||||
"camlistore.org/pkg/auth"
|
"camlistore.org/pkg/auth"
|
||||||
"camlistore.org/pkg/blob"
|
"camlistore.org/pkg/blob"
|
||||||
|
"camlistore.org/pkg/buildinfo"
|
||||||
"camlistore.org/pkg/client/android"
|
"camlistore.org/pkg/client/android"
|
||||||
"camlistore.org/pkg/jsonconfig"
|
"camlistore.org/pkg/jsonconfig"
|
||||||
"camlistore.org/pkg/jsonsign"
|
"camlistore.org/pkg/jsonsign"
|
||||||
|
@ -46,7 +47,10 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func AddFlags() {
|
func AddFlags() {
|
||||||
defaultPath := osutil.UserClientConfigPath()
|
defaultPath := "/x/y/z/we're/in-a-test"
|
||||||
|
if !buildinfo.TestingLinked() {
|
||||||
|
defaultPath = osutil.UserClientConfigPath()
|
||||||
|
}
|
||||||
flag.StringVar(&flagServer, "server", "", "Camlistore server prefix. If blank, the default from the \"server\" field of "+defaultPath+" is used. Acceptable forms: https://you.example.com, example.com:1345 (https assumed), or http://you.example.com/alt-root")
|
flag.StringVar(&flagServer, "server", "", "Camlistore server prefix. If blank, the default from the \"server\" field of "+defaultPath+" is used. Acceptable forms: https://you.example.com, example.com:1345 (https assumed), or http://you.example.com/alt-root")
|
||||||
flag.StringVar(&flagSecretRing, "secret-keyring", "", "GnuPG secret keyring file to use.")
|
flag.StringVar(&flagSecretRing, "secret-keyring", "", "GnuPG secret keyring file to use.")
|
||||||
}
|
}
|
||||||
|
@ -442,12 +446,11 @@ var osutilHomeDir = osutil.HomeDir // changed by tests
|
||||||
func newIgnoreChecker(ignoredFiles []string) func(path string) (shouldIgnore bool) {
|
func newIgnoreChecker(ignoredFiles []string) func(path string) (shouldIgnore bool) {
|
||||||
var fns []func(string) bool
|
var fns []func(string) bool
|
||||||
|
|
||||||
home := osutilHomeDir()
|
|
||||||
// copy of ignoredFiles for us to mutate
|
// copy of ignoredFiles for us to mutate
|
||||||
ignFiles := append([]string(nil), ignoredFiles...)
|
ignFiles := append([]string(nil), ignoredFiles...)
|
||||||
for k, v := range ignFiles {
|
for k, v := range ignFiles {
|
||||||
if strings.HasPrefix(v, filepath.FromSlash("~/")) {
|
if strings.HasPrefix(v, filepath.FromSlash("~/")) {
|
||||||
ignFiles[k] = filepath.Join(home, v[2:])
|
ignFiles[k] = filepath.Join(osutilHomeDir(), v[2:])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We cache the ignoredFiles patterns in 3 categories (not necessarily exclusive):
|
// We cache the ignoredFiles patterns in 3 categories (not necessarily exclusive):
|
||||||
|
|
Loading…
Reference in New Issue