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

Method getFileInformationFromEvent

pkg/devspace/sync/upstream.go:433–466  ·  view source on GitHub ↗
(events []notify.EventInfo)

Source from the content-addressed store, hash-verified

431}
432
433func (u *upstream) getFileInformationFromEvent(events []notify.EventInfo) ([]*FileInformation, error) {
434 u.sync.fileIndex.fileMapMutex.Lock()
435 defer u.sync.fileIndex.fileMapMutex.Unlock()
436
437 changes := make([]*FileInformation, 0, len(events))
438 for _, event := range events {
439 fileInfo, ok := event.(*FileInformation)
440
441 // if the change is sent from the initial sync don't evaluate it
442 if ok {
443 changes = append(changes, fileInfo)
444 } else {
445 u.sync.log.Debugf("Upstream - Event from filesystem for %s", event.Path())
446
447 // check if path is correct
448 fullPath := event.Path()
449 if !strings.HasPrefix(filepath.ToSlash(fullPath), filepath.ToSlash(u.sync.LocalPath)+"/") {
450 u.sync.log.Infof("Upstream - unexpected upload path %s", fullPath)
451 continue
452 }
453
454 // Determine what kind of change we got (Create or Remove)
455 relativePath := getRelativeFromFullPath(fullPath, u.sync.LocalPath)
456 newChanges, err := u.evaluateChange(relativePath, fullPath)
457 if err != nil {
458 return nil, errors.Wrap(err, "evaluate change")
459 }
460
461 changes = append(changes, newChanges...)
462 }
463 }
464
465 return changes, nil
466}
467
468func (u *upstream) evaluateChange(relativePath, fullPath string) ([]*FileInformation, error) {
469 stat, err := os.Stat(fullPath)

Callers 1

mainLoopMethod · 0.95

Calls 7

evaluateChangeMethod · 0.95
LockMethod · 0.80
UnlockMethod · 0.80
getRelativeFromFullPathFunction · 0.70
PathMethod · 0.65
DebugfMethod · 0.45
InfofMethod · 0.45

Tested by

no test coverage detected