mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
Expand tilde in repository path (fixes #8)
This commit is contained in:
parent
48603a1619
commit
46d828e349
13
main.go
13
main.go
@ -75,9 +75,7 @@ func main() {
|
||||
if len(opts.Debug.TraceModel) > 0 || opts.Debug.LogSource {
|
||||
logger = log.New(os.Stderr, "", log.Lshortfile|log.Ldate|log.Ltime|log.Lmicroseconds)
|
||||
}
|
||||
if strings.HasPrefix(opts.ConfDir, "~/") {
|
||||
opts.ConfDir = strings.Replace(opts.ConfDir, "~", getHomeDir(), 1)
|
||||
}
|
||||
opts.ConfDir = expandTilde(opts.ConfDir)
|
||||
|
||||
infoln("Version", Version)
|
||||
|
||||
@ -124,7 +122,7 @@ func main() {
|
||||
config = ini.Parse(cf)
|
||||
cf.Close()
|
||||
|
||||
var dir = config.Get("repository", "dir")
|
||||
var dir = expandTilde(config.Get("repository", "dir"))
|
||||
|
||||
// Create a map of desired node connections based on the configuration file
|
||||
// directives.
|
||||
@ -388,6 +386,13 @@ func ensureDir(dir string, mode int) {
|
||||
}
|
||||
}
|
||||
|
||||
func expandTilde(p string) string {
|
||||
if strings.HasPrefix(p, "~/") {
|
||||
return strings.Replace(p, "~", getHomeDir(), 1)
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func getHomeDir() string {
|
||||
home := os.Getenv("HOME")
|
||||
if home == "" {
|
||||
|
Loading…
Reference in New Issue
Block a user