diff options
Diffstat (limited to 'cmd/podman/cp.go')
-rw-r--r-- | cmd/podman/cp.go | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/cmd/podman/cp.go b/cmd/podman/cp.go index 6c5e4ee43..9d00dbe59 100644 --- a/cmd/podman/cp.go +++ b/cmd/podman/cp.go @@ -327,20 +327,6 @@ func copy(src, destPath, dest string, idMappingOpts storage.IDMappingOptions, ch } return nil } - if !archive.IsArchivePath(srcPath) { - // This srcPath is a file, and either it's not an - // archive, or we don't care whether or not it's an - // archive. - destfi, err := os.Stat(destPath) - if err != nil { - if !os.IsNotExist(err) { - return errors.Wrapf(err, "failed to get stat of dest path %s", destPath) - } - } - if destfi != nil && destfi.IsDir() { - destPath = filepath.Join(destPath, filepath.Base(srcPath)) - } - } if extract { // We're extracting an archive into the destination directory. @@ -351,9 +337,16 @@ func copy(src, destPath, dest string, idMappingOpts storage.IDMappingOptions, ch return nil } - if destDirIsExist || strings.HasSuffix(dest, string(os.PathSeparator)) { + destfi, err := os.Stat(destPath) + if err != nil { + if !os.IsNotExist(err) { + return errors.Wrapf(err, "failed to get stat of dest path %s", destPath) + } + } + if destfi != nil && destfi.IsDir() { 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 { |