Skip to content

Support copying files to a directory#3604

Open
jerrykan wants to merge 1 commit into
getpelican:mainfrom
jerrykan:copyfile_to_dir
Open

Support copying files to a directory#3604
jerrykan wants to merge 1 commit into
getpelican:mainfrom
jerrykan:copyfile_to_dir

Conversation

@jerrykan

@jerrykan jerrykan commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

This restores the ability for the copy() function to copy files to a directory. The changes are essentially the same as what is used in the Python standard library.

Pull Request Checklist

Resolves: #3442

  • Ensured tests pass and (if applicable) updated functional test output
  • Conformed to code style guidelines by running appropriate linting tools
  • Added tests for changed code
  • Updated documentation for changed code

@justinmayer

Copy link
Copy Markdown
Member

Hi John. Thank you for the submission. In order to prevent future code modifications from causing regressions and breaking the behavior you are enabling here, could you add a test that ensures your target use case is covered?

Since commit dbe0b11 the `copy()` function no longer supports copying
files to a directory. The change in behaviour has lead to at least one
regression[1]. This restore the previous behaviour.

[1] getpelican#3442
@jerrykan

jerrykan commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

Hi Justin I've added a test to cover copying a file to and existing directory.

While creating the test I noticed a possible edge-case where if copy() is used to try to copy a file to a directory that does not exist (ie. a/a.txt -> b0/b1/). If the b0/b1/ directory does not exist, then the file will be copied to b0/b1 (where b1 is a file).

There is no equivalent at the OS level (because copying a file wouldn't automatically create any directories) so the expected behavior is probably undefined. I'm not sure if this is an edge case that is worth worrying about.

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

Successfully merging this pull request may close these issues.

copy over directories using extra_path_metadata

2 participants