From bb7b0aad0eb7874c97911d8a27532100f1a32232 Mon Sep 17 00:00:00 2001 From: Qi Wang Date: Thu, 23 May 2019 14:30:02 -0400 Subject: fix bug dest path of copying tar when podman cp tar without --extract flag, if the destination already exists, or ends with path seprator, cp the tar under the directory, otherwise copy the tar named with the destination Signed-off-by: Qi Wang --- cmd/podman/cp.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cmd/podman') diff --git a/cmd/podman/cp.go b/cmd/podman/cp.go index 4cb8a8c54..8240cc193 100644 --- a/cmd/podman/cp.go +++ b/cmd/podman/cp.go @@ -272,6 +272,10 @@ func copy(src, destPath, dest string, idMappingOpts storage.IDMappingOptions, ch } return nil } + + if destDirIsExist || strings.HasSuffix(dest, string(os.PathSeparator)) { + destPath = filepath.Join(destPath, filepath.Base(srcPath)) + } // Copy the file, preserving attributes. logrus.Debugf("copying %q to %q", srcPath, destPath) if err = copyFileWithTar(srcPath, destPath); err != nil { -- cgit v1.2.3-54-g00ecf