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

Method AddSymlink

pkg/devspace/sync/upstream.go:596–630  ·  view source on GitHub ↗
(relativePath, absPath string)

Source from the content-addressed store, hash-verified

594}
595
596func (u *upstream) AddSymlink(relativePath, absPath string) (os.FileInfo, error) {
597 // Get real path
598 targetPath, err := filepath.EvalSymlinks(absPath)
599 if err != nil {
600 u.sync.log.Infof("Warning: resolving symlink of %s: %v", absPath, err)
601 return nil, nil // errors.Errorf("Error resolving symlink of %s: %v", absPath, err)
602 }
603
604 stat, err := os.Stat(targetPath)
605 if err != nil {
606 u.sync.log.Infof("Warning: stating symlink %s: %v", targetPath, err)
607 return nil, nil // errors.Errorf("Error stating symlink %s: %v", targetPath, err)
608 }
609
610 // Check if we already added the symlink
611 if _, ok := u.symlinks[absPath]; ok {
612 return stat, nil
613 }
614
615 // Check if symlink is ignored
616 if u.sync.ignoreMatcher != nil {
617 if u.sync.ignoreMatcher.Matches(relativePath, stat.IsDir()) {
618 return nil, nil
619 }
620 }
621
622 symlink, err := NewSymlink(u, absPath, targetPath, stat.IsDir(), u.sync.ignoreMatcher)
623 if err != nil {
624 return nil, errors.Errorf("Cannot create symlink object for %s: %v", absPath, err)
625 }
626
627 u.symlinks[absPath] = symlink
628
629 return stat, nil
630}
631
632func (u *upstream) RemoveSymlinks(absPath string) {
633 for key, symlink := range u.symlinks {

Callers 2

evaluateChangeMethod · 0.80
deltaStateMethod · 0.80

Calls 5

NewSymlinkFunction · 0.85
MatchesMethod · 0.65
InfofMethod · 0.45
IsDirMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected