diff --git a/internal/package.go b/internal/package.go index 80c11ba3..6fbca215 100644 --- a/internal/package.go +++ b/internal/package.go @@ -83,12 +83,8 @@ func (l *LocationPackage) Link() (*Package, error) { sourcePackage := l.from targetPackage := l.ConvertLocation() // If the mock path already exists, delete it first. - if util.FileExists(mockPath) { - logger.Debugf("Removing old package path: %s\n", mockPath) - if err := os.RemoveAll(mockPath); err != nil { - return nil, err - } - } + logger.Debugf("Removing old package path: %s\n", mockPath) + _ = os.RemoveAll(mockPath) hasAddition := len(targetPackage.Additions) != 0 if !hasAddition { logger.Debugf("Create symlink %s -> %s\n", sourcePackage.Main.Path, targetPackage.Main.Path) diff --git a/internal/util/file.go b/internal/util/file.go index 8e326f93..aaa86cb2 100644 --- a/internal/util/file.go +++ b/internal/util/file.go @@ -26,30 +26,11 @@ import ( ) func FileExists(filename string) bool { - fileInfo, err := os.Lstat(filename) - if err != nil { - if os.IsNotExist(err) { - return false - } + _, err := os.Stat(filename) + if os.IsNotExist(err) { return false } - - if fileInfo.Mode()&os.ModeSymlink != 0 { - target, err := os.Readlink(filename) - if err != nil { - return false - } - _, err = os.Stat(target) - if err != nil { - if os.IsNotExist(err) { - return false - } - return false - } - return true - } - - return true + return err == nil } func CopyFile(src, dst string) error {