Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected behavior for "directory to new directory" depends on trailing slash #1500

Open
Github-dm-CDE opened this issue Jan 15, 2024 · 5 comments

Comments

@Github-dm-CDE
Copy link

In Copying files and directories, 1f case "directory to new directory", it is stated that the trailing slashes in both source and target are optional. However, if source/subdir and target/newdir/ are being used, the resulting target structure is the following:

📁 target
 └── 📁 newdir
     └── 📁 subdir
          ├── 📄 subfile1
          ├── 📄 subfile2
          └── 📁 nesteddir
              └── 📄 nestedfile

Basically the subdir folder itself is taken too, not only its content.
This can be reproduced e.g. out of the box with LocalFileSystem() and the copy() method.

Is such output expected?

@martindurant
Copy link
Member

Yes, this sounds exactly as designed, and what you would expect with a posix CLI. It also depends on whether the target directory already exists or not.

@CM000n
Copy link

CM000n commented Jan 16, 2024

Is then the behaviour specified in the documentation for single source to single target case 1f. Directory to new directoy incorrect @martindurant? Here the documentation specifies an expected output of:

cp("source/subdir/", "target/newdir/", recursive=True)
(Whether with or without trailing slashes should result in the following structure)

📁 target
 └── 📁 newdir
     ├── 📄 subfile1
     └── 📄 subfile2
         └── 📁 nesteddir
             └── 📄 nestedfile

@martindurant
Copy link
Member

"source/subdir/"

This path contains a terminal "/", so that is probably the difference. It would be best to make the cases with and without, versus expectations, test cases to be fixed. This is obviously not simple territory.

@xebab
Copy link

xebab commented Jan 17, 2024

The difference is definitely the trailing slash in the source path.

The thing is that the documentation explicitly states

Trailing slashes on both source and target are optional and do not affect the result.

So the first thing to clarify would be whether there is a problem in the documentation or in the implementation.

@xebab
Copy link

xebab commented Jan 18, 2024

I think that the documentation is correct, after all. There are test cases that are supposed to test that trailing slashes are optional.

Those tests were not executed, however. After enabling them they fail in accordance with the issue reported here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants