From 073abff176d88e6aceffb49fa801a8cfc2ef7657 Mon Sep 17 00:00:00 2001 From: Peter van Zetten Date: Thu, 11 Oct 2018 11:00:50 +0100 Subject: [PATCH] Improve IsDestDir functionality with filesystem info Add a check for FileInfo to determine whether a given string is a directory path. If any error occurs, fall back to the naive string check. Fixes #365 --- pkg/util/command_util.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/util/command_util.go b/pkg/util/command_util.go index b6574faa8d..828b9e8273 100644 --- a/pkg/util/command_util.go +++ b/pkg/util/command_util.go @@ -133,7 +133,14 @@ func matchSources(srcs, files []string) ([]string, error) { } func IsDestDir(path string) bool { - return strings.HasSuffix(path, "/") || path == "." + // try to stat the path + fileInfo, err := os.Stat(path) + if err != nil { + // fall back to string-based determination + return strings.HasSuffix(path, "/") || path == "." + } + // if it's a real path, check the fs response + return fileInfo.IsDir() } // DestinationFilepath returns the destination filepath from the build context to the image filesystem