From d9b3f276b8e318b797cd9ee746da6c86051569de Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Mon, 10 Oct 2016 21:03:40 +0100 Subject: [PATCH] Fix remote path calcuation when continuously mirroring fs dir to any target (#1853) --- cmd/mirror-main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/mirror-main.go b/cmd/mirror-main.go index 48c98751..4c5fa70c 100644 --- a/cmd/mirror-main.go +++ b/cmd/mirror-main.go @@ -397,6 +397,16 @@ func (ms *mirrorSession) watch() { // again, by replacing the sourceUrlFull with the sourceAlias. This url will be // used to mirror. sourceAlias, sourceURLFull, _ := mustExpandAlias(ms.sourceURL) + + // If the passed source URL points to fs, fetch the absolute src path + // to correctly calculate targetPath + if sourceAlias == "" { + tmpSrcUrl, err := filepath.Abs(sourceURLFull) + if err == nil { + sourceURLFull = tmpSrcUrl + } + } + sourceURL := newClientURL(event.Path) aliasedPath := strings.Replace(event.Path, sourceURLFull, ms.sourceURL, -1)