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

Method applyChange

helper/server/downstream.go:363–406  ·  view source on GitHub ↗
(newState map[string]*remote.Change, fullPath string)

Source from the content-addressed store, hash-verified

361}
362
363func (d *Downstream) applyChange(newState map[string]*remote.Change, fullPath string) {
364 fullPath = strings.TrimSuffix(fullPath, "/")
365
366 relativePath := fullPath[len(d.options.RemotePath):]
367
368 // in any case we mark this part of the tree as dirty and delete it
369 if old, ok := d.watchedFiles[fullPath]; ok {
370 if old.IsDir {
371 deletePathFromState(newState, fullPath)
372 } else {
373 delete(newState, fullPath)
374 }
375 }
376
377 // check if the path still exists
378 stat, err := os.Stat(fullPath)
379 if err != nil {
380 return
381 } else if d.ignoreMatcher != nil && !d.ignoreMatcher.RequireFullScan() && d.ignoreMatcher.Matches(relativePath, stat.IsDir()) {
382 return
383 }
384
385 if stat.IsDir() {
386 if d.ignoreMatcher == nil || !d.ignoreMatcher.RequireFullScan() || !d.ignoreMatcher.Matches(relativePath, true) {
387 newState[fullPath] = &remote.Change{
388 Path: fullPath,
389 IsDir: true,
390 }
391 }
392
393 walkDir(d.options.RemotePath, fullPath, d.ignoreMatcher, newState, d.options.NoRecursiveWatch, time.Duration(d.options.Throttle)*time.Millisecond)
394 } else {
395 if d.ignoreMatcher == nil || !d.ignoreMatcher.RequireFullScan() || !d.ignoreMatcher.Matches(relativePath, false) {
396 newState[fullPath] = &remote.Change{
397 Path: fullPath,
398 Size: stat.Size(),
399 MtimeUnix: stat.ModTime().Unix(),
400 MtimeUnixNano: stat.ModTime().UnixNano(),
401 Mode: uint32(stat.Mode()),
402 IsDir: false,
403 }
404 }
405 }
406}
407
408func deletePathFromState(state map[string]*remote.Change, path string) {
409 for k := range state {

Callers 1

getWatchStateMethod · 0.95

Calls 8

deletePathFromStateFunction · 0.85
walkDirFunction · 0.85
RequireFullScanMethod · 0.65
MatchesMethod · 0.65
IsDirMethod · 0.45
SizeMethod · 0.45
ModTimeMethod · 0.45
ModeMethod · 0.45

Tested by

no test coverage detected