Skip to content

Commit

Permalink
Fix test_copy bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua committed Sep 6, 2024
1 parent 9a98a00 commit b0c0bea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions tosfs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("-")
Expand Down
4 changes: 2 additions & 2 deletions tosfs/tests/test_fsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit b0c0bea

Please sign in to comment.