From c2be2ecd316d3d02a31f81990428fa26d19a4702 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Mon, 6 Nov 2023 15:32:58 +0000 Subject: [PATCH] Fix copying of files. --- cista/protocol.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cista/protocol.py b/cista/protocol.py index 2bdf775..02a35d9 100644 --- a/cista/protocol.py +++ b/cista/protocol.py @@ -75,13 +75,16 @@ class Cp(ControlBase): if not dst.is_dir(): raise BadRequest("The destination must be a directory") for p in sel: - # Note: copies as dst rather than in dst unless name is appended. - shutil.copytree( - p, - dst / p.name, - dirs_exist_ok=True, - ignore_dangling_symlinks=True, - ) + if p.is_dir(): + # Note: copies as dst rather than in dst unless name is appended. + shutil.copytree( + p, + dst / p.name, + dirs_exist_ok=True, + ignore_dangling_symlinks=True, + ) + else: + shutil.copy2(p, dst) ControlTypes = MkDir | Rename | Rm | Mv | Cp