mirror of
https://github.com/containers/podman.git
synced 2025-12-05 12:52:12 +08:00
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>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user