summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorQi Wang <qiwan@redhat.com>2019-05-23 14:30:02 -0400
committerQi Wang <qiwan@redhat.com>2019-05-24 11:51:30 -0400
commitbb7b0aad0eb7874c97911d8a27532100f1a32232 (patch)
treed7e960c1310076ddfa99ab77f7cfe941b02d87bc /cmd
parent579fd01f7df929373a6b68a4c4dda17084832db4 (diff)
downloadpodman-bb7b0aad0eb7874c97911d8a27532100f1a32232.tar.gz
podman-bb7b0aad0eb7874c97911d8a27532100f1a32232.tar.bz2
podman-bb7b0aad0eb7874c97911d8a27532100f1a32232.zip
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 <qiwan@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/cp.go4
1 files changed, 4 insertions, 0 deletions
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 {