diff options
author | Qi Wang <qiwan@redhat.com> | 2019-09-24 11:35:49 -0400 |
---|---|---|
committer | Qi Wang <qiwan@redhat.com> | 2019-09-25 12:48:05 -0400 |
commit | 0144c3796ba3dd0555e35fd2cc3f76bde10a90a0 (patch) | |
tree | 3548d0de8326852e12d965492b2cad7fa131953a /cmd/podman | |
parent | f197ebe8519198ea24a0a395ffeb97711a248c27 (diff) | |
download | podman-0144c3796ba3dd0555e35fd2cc3f76bde10a90a0.tar.gz podman-0144c3796ba3dd0555e35fd2cc3f76bde10a90a0.tar.bz2 podman-0144c3796ba3dd0555e35fd2cc3f76bde10a90a0.zip |
fix cp none exists dest path ends with '/'
close #3894
This patch let podman cp return 'no such file or directory' error if DEST_PATH does not exist and ends with / when copying file.
Signed-off-by: Qi Wang <qiwan@redhat.com>
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/cp.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/cmd/podman/cp.go b/cmd/podman/cp.go index 7205f9357..75a23afd6 100644 --- a/cmd/podman/cp.go +++ b/cmd/podman/cp.go @@ -290,7 +290,7 @@ func copy(src, destPath, dest string, idMappingOpts storage.IDMappingOptions, ch } destdir := destPath - if !srcfi.IsDir() && !strings.HasSuffix(dest, string(os.PathSeparator)) { + if !srcfi.IsDir() { destdir = filepath.Dir(destPath) } _, err = os.Stat(destdir) @@ -329,7 +329,7 @@ func copy(src, destPath, dest string, idMappingOpts storage.IDMappingOptions, ch destfi, err := os.Stat(destPath) if err != nil { - if !os.IsNotExist(err) { + if !os.IsNotExist(err) || strings.HasSuffix(dest, string(os.PathSeparator)) { return errors.Wrapf(err, "failed to get stat of dest path %s", destPath) } } |