(relativePath, absPath string)
| 594 | } |
| 595 | |
| 596 | func (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 | |
| 632 | func (u *upstream) RemoveSymlinks(absPath string) { |
| 633 | for key, symlink := range u.symlinks { |
no test coverage detected