You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# take an existing filesrc=S3Path("s3://my-bucket/file.txt")
# and copy it into non-existent folderdst=S3Path("s3://my-bucket/destination/")
src.copy(dst)
Current behavior
Creates a file with name / inside the folder s3://my-bucket/destination/
Expected behavior
The file s3://my-bucket/destination/file.txt is created
The text was updated successfully, but these errors were encountered:
FWIW .copy is meant to mimic the behavior of the copy function from shutil, which has similarly potentially unintuitive behavior (it both strips the delimiter and writes dst as a file).
Since this is CloudPath only API that is not on a Path object, we do have some leeway on deciding if there is a better approach. However, there is some ambiguity in the right approach since s3://bucket/file-end-in-slash/ is a valid name for a blob/object on at least some of the providers.
Some options:
(as suggested above) Treat CloudPaths ending in / as directories in copy even if they don't exist
Add a kwarg/setting to treat CloudPaths ending in / as directories in copy explicitly
Add a warning if we ever write to a CloudPath ending in / (since this is likely user error)
Leave as-is and document
If we document, the workaround is to concat the paths yourself (since not all providers even support empty folders):
Steps to reproduce:
Current behavior
Creates a file with name
/
inside the folders3://my-bucket/destination/
Expected behavior
The file
s3://my-bucket/destination/file.txt
is createdThe text was updated successfully, but these errors were encountered: