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

Method watch

helper/server/downstream.go:328–361  ·  view source on GitHub ↗
(stopChan chan struct{})

Source from the content-addressed store, hash-verified

326}
327
328func (d *Downstream) watch(stopChan chan struct{}) {
329 for {
330 select {
331 case <-stopChan:
332 return
333 case event, ok := <-d.events:
334 if !ok {
335 return
336 }
337
338 d.changesMutex.Lock()
339 // re-sync if overflow
340 if len(d.events) >= 999 {
341 d.lastRescan = nil
342 } else {
343 // check if parent folder might be already in changes then skip
344 // this saves us a lot of folder crawling later on
345 parts := strings.Split(filepath.ToSlash(event.Path()), "/")
346 found := false
347 for i := len(parts) - 1; i > 0; i-- {
348 path := strings.Join(parts[:i], "/")
349 if d.changes[path] {
350 found = true
351 break
352 }
353 }
354 if !found {
355 d.changes[event.Path()] = true
356 }
357 }
358 d.changesMutex.Unlock()
359 }
360 }
361}
362
363func (d *Downstream) applyChange(newState map[string]*remote.Change, fullPath string) {
364 fullPath = strings.TrimSuffix(fullPath, "/")

Callers 1

StartDownstreamServerFunction · 0.95

Calls 3

LockMethod · 0.80
UnlockMethod · 0.80
PathMethod · 0.65

Tested by

no test coverage detected