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
This commit is contained in:
Peter van Zetten 2018-10-11 11:00:50 +01:00
parent 03db09e95f
commit 073abff176
1 changed files with 8 additions and 1 deletions

View File

@ -133,8 +133,15 @@ func matchSources(srcs, files []string) ([]string, error) {
}
func IsDestDir(path string) bool {
// 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
// If source is a file: