Merge pull request #2221 from thaJeztah/fix_docker_cp_npe

docker cp: prevent NPE when failing to stat destination
This commit is contained in:
Silvin Lubecki 2019-12-09 21:40:42 +01:00 committed by GitHub
commit 79578882a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -139,6 +139,10 @@ func ValidateOutputPath(path string) error {
// check whether `path` points to a regular file
// (if the path exists and doesn't point to a directory)
if fileInfo, err := os.Stat(path); !os.IsNotExist(err) {
if err != nil {
return err
}
if fileInfo.Mode().IsDir() || fileInfo.Mode().IsRegular() {
return nil
}