diff --git a/tosfs/core.py b/tosfs/core.py index 1534909..86bf5de 100644 --- a/tosfs/core.py +++ b/tosfs/core.py @@ -890,6 +890,10 @@ def cp_file( bucket, key, vers = self._split_path(path1) info = self.info(path1, bucket, key, version_id=vers) + if info["type"] == "directory": + logger.warning(f"Do not support copy directory {path1}.") + return + size = info["size"] _, _, parts_suffix = info.get("ETag", "").strip('"').partition("-") diff --git a/tosfs/tests/test_fsspec.py b/tosfs/tests/test_fsspec.py index f846306..7384f0d 100644 --- a/tosfs/tests/test_fsspec.py +++ b/tosfs/tests/test_fsspec.py @@ -49,9 +49,9 @@ def test_copy(fsspecfs: Any, bucket: str, temporary_workspace: str): ), "Content mismatch in copied file" # Test Case 2: Copy directory recursively - copy_dir_dest = f"{bucket}/{temporary_workspace}/copy_dir/" + copy_dir_dest = f"{bucket}/{temporary_workspace}/copy_dir" fsspecfs.mkdir(copy_dir_dest) - fsspecfs.copy(subdir_path, copy_dir_dest, recursive=True) + fsspecfs.copy(subdir_path.rstrip("/") + "/", copy_dir_dest, recursive=True) assert fsspecfs.exists( f"{copy_dir_dest}/file1.txt" ), "Failed to copy directory recursively"