From c20d612736aee5e4472deb20008bf9b7a18ad5f2 Mon Sep 17 00:00:00 2001 From: Simon Frei Date: Sat, 4 Mar 2017 07:49:48 +0000 Subject: [PATCH] cmd/syncthing, lib/model: Handle rel/abs paths for config/protected paths (fixes #3183) GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3995 --- cmd/syncthing/main.go | 8 +++++++- lib/model/model.go | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 290ba719..3dcfce8c 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -344,7 +344,13 @@ func main() { if options.confDir != "" { // Not set as default above because the string can be really long. - baseDirs["config"] = options.confDir + if !filepath.IsAbs(options.confDir) { + path, err := filepath.Abs(options.confDir) + if err != nil { + l.Fatalln(err) + } + baseDirs["config"] = path + } } if err := expandLocations(); err != nil { diff --git a/lib/model/model.go b/lib/model/model.go index 9d7ab887..273d3e7d 100644 --- a/lib/model/model.go +++ b/lib/model/model.go @@ -285,7 +285,8 @@ func (m *Model) warnAboutOverwritingProtectedFiles(folder string) { } // check if file is ignored - if ignores.Match(protectedFilePath).IsIgnored() { + relPath, _ := filepath.Rel(folderLocation, protectedFilePath) + if ignores.Match(relPath).IsIgnored() { continue }