docker cp: prevent NPE when failing to stat destination

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2019-12-09 15:32:02 +01:00
parent 8547dfcff7
commit 585ec4da97
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
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 // check whether `path` points to a regular file
// (if the path exists and doesn't point to a directory) // (if the path exists and doesn't point to a directory)
if fileInfo, err := os.Stat(path); !os.IsNotExist(err) { if fileInfo, err := os.Stat(path); !os.IsNotExist(err) {
if err != nil {
return err
}
if fileInfo.Mode().IsDir() || fileInfo.Mode().IsRegular() { if fileInfo.Mode().IsDir() || fileInfo.Mode().IsRegular() {
return nil return nil
} }