MCPcopy Index your code
hub / github.com/devspace-sh/devspace / NewSync

Function NewSync

pkg/devspace/sync/sync.go:90–136  ·  view source on GitHub ↗

NewSync creates a new sync for the given local path

(ctx context.Context, localPath string, options Options)

Source from the content-addressed store, hash-verified

88
89// NewSync creates a new sync for the given local path
90func NewSync(ctx context.Context, localPath string, options Options) (*Sync, error) {
91 cancelCtx, cancel := context.WithCancel(ctx)
92
93 // we have to resolve the real local path, because the watcher gives us the real path always
94 realLocalPath, err := filepath.EvalSymlinks(localPath)
95 if err != nil {
96 cancel()
97 return nil, errors.Wrap(err, "eval symlinks")
98 }
99
100 absoluteLocalPath, err := filepath.Abs(realLocalPath)
101 if err != nil {
102 cancel()
103 return nil, errors.Wrap(err, "absolute path")
104 }
105
106 absoluteRealLocalPath, err := filepath.EvalSymlinks(absoluteLocalPath)
107 if err != nil {
108 cancel()
109 return nil, errors.Wrap(err, "eval symlinks")
110 }
111
112 // We exclude the sync log to prevent an endless loop in upstream
113 newExcludes := []string{}
114 newExcludes = append(newExcludes, ".devspace/")
115 newExcludes = append(newExcludes, options.ExcludePaths...)
116 options.ExcludePaths = newExcludes
117
118 // Create sync structure
119 s := &Sync{
120 ctx: cancelCtx,
121 cancelCtx: cancel,
122
123 LocalPath: absoluteRealLocalPath,
124 Options: options,
125
126 fileIndex: newFileIndex(),
127 log: options.Log,
128 }
129
130 err = s.initIgnoreParsers()
131 if err != nil {
132 return nil, errors.Wrap(err, "init ignore parsers")
133 }
134
135 return s, nil
136}
137
138// Error handles a sync error
139func (s *Sync) Error(err error) {

Callers 2

initClientMethod · 0.92
createTestSyncClientFunction · 0.85

Calls 2

initIgnoreParsersMethod · 0.95
newFileIndexFunction · 0.85

Tested by 1

createTestSyncClientFunction · 0.68