Skip to content

Commit 24c48a9

Browse files
committed
Fix problem when watching on symlinked path
1 parent 463cd8f commit 24c48a9

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

pkg/devspace/sync/sync_config.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"io/ioutil"
55
"os"
66
"path"
7+
"path/filepath"
78
"sync"
89
"time"
910

@@ -101,6 +102,14 @@ func (s *SyncConfig) Error(err error) {
101102
}
102103

103104
func (s *SyncConfig) setup() error {
105+
// we have to resolve the real local path, because the watcher gives us the real path always
106+
realLocalPath, err := filepath.EvalSymlinks(s.WatchPath)
107+
if err != nil {
108+
return errors.Trace(err)
109+
}
110+
111+
s.WatchPath = realLocalPath
112+
104113
if s.ExcludePaths == nil {
105114
s.ExcludePaths = make([]string, 0, 2)
106115
}
@@ -125,7 +134,7 @@ func (s *SyncConfig) setup() error {
125134
syncLog.SetLevel(logrus.InfoLevel)
126135
}
127136

128-
err := s.initIgnoreParsers()
137+
err = s.initIgnoreParsers()
129138
if err != nil {
130139
return errors.Trace(err)
131140
}

pkg/devspace/sync/sync_config_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ func initTestDirs(t *testing.T) (string, string, string) {
3232
t.Fatalf("Couldn't create test dir: %v", err)
3333
}
3434

35+
testRemotePath, err = filepath.EvalSymlinks(testRemotePath)
36+
if err != nil {
37+
t.Fatal(err)
38+
}
39+
40+
testLocalPath, err = filepath.EvalSymlinks(testLocalPath)
41+
if err != nil {
42+
t.Fatal(err)
43+
}
44+
45+
outside, err = filepath.EvalSymlinks(outside)
46+
if err != nil {
47+
t.Fatal(err)
48+
}
49+
3550
return testRemotePath, testLocalPath, outside
3651
}
3752

@@ -55,6 +70,7 @@ func TestInitialSync(t *testing.T) {
5570
remote, local, outside := initTestDirs(t)
5671
defer os.RemoveAll(remote)
5772
defer os.RemoveAll(local)
73+
defer os.RemoveAll(outside)
5874

5975
filesToCheck, foldersToCheck := makeBasicTestCases()
6076

0 commit comments

Comments
 (0)