diff --git a/cli/internal/fs/copy_file.go b/cli/internal/fs/copy_file.go index 4f89d81cbf536..cae69ef41bbe8 100644 --- a/cli/internal/fs/copy_file.go +++ b/cli/internal/fs/copy_file.go @@ -79,17 +79,17 @@ func Walk(rootPath string, callback func(name string, isDir bool) error) error { // WalkMode is like Walk but the callback receives an additional type specifying the file mode type. // N.B. This only includes the bits of the mode that determine the mode type, not the permissions. func WalkMode(rootPath string, callback func(name string, isDir bool, mode os.FileMode) error) error { - // Compatibility with filepath.Walk which allows passing a file as the root argument. - if info, err := os.Lstat(rootPath); err != nil { - return err - } else if !info.IsDir() { - return callback(rootPath, false, info.Mode()) - } return godirwalk.Walk(rootPath, &godirwalk.Options{ Callback: func(name string, info *godirwalk.Dirent) error { - return callback(name, info.IsDir(), info.ModeType()) + if isDirLike, err := info.IsDirOrSymlinkToDir(); err == nil { + return callback(name, isDirLike, info.ModeType()) + } else { + return err + } }, - Unsorted: true, + Unsorted: true, + AllowNonDirectory: true, + FollowSymbolicLinks: false, }) }