Skip to content

Conversation

@qrvd
Copy link
Contributor

@qrvd qrvd commented Oct 18, 2025

ISSUE TYPE

x Bug fix

RUNTIME ENVIRONMENT

  • Operating system and version:
  • Terminal emulator and version: Tilix 1.9.5
  • Python version: 3.11.2
  • Ranger version/commit: master 6d5e0d8
  • Locale: en_US.UTF-8

CHECKLIST

  • The CONTRIBUTING document has been read [REQUIRED]
  • All changes follow the code style [REQUIRED]
  • All new and existing tests pass [REQUIRED]
  • Changes require config files to be updated
    • Config files have been updated
  • Changes require documentation to be updated
    • Documentation has been updated
  • Changes require tests to be updated
    • Tests have been updated

DESCRIPTION

Record the destination directory in a set of "ignored trees" and pass this variable down to recursive instances of copytree().

Remove the ignore keyword argument mostly because Pylint complains that the function is too big otherwise. Fortunately it was never used anyway.

MOTIVATION AND CONTEXT

When copying a folder into its subtree, copytree() will
recursively copy the newly created directory, and enter an infinite recursive descent, because it doesn't know which of the files it already created.

This is somewhat of an edge case and some file managers outright refuse to handle it. Even the version of cp running on my machine won't do this. But it seems like a simple bug for us to fix and it'd give the user more freedom.

#1925

TESTING

Create a directory, and create another directory inside of it.

Optionally create additional files and add them to either directory.

Now copy the first directory (:copy), navigate into the second directoy, and run the :paste command. All the contents of the source directory will be in the second directory as a user would expect.

Changes to shutil_generatorized affect the CopyLoader class, which is its only user. The specific code paths involved would only affect copying directories using :copy followed by :paste.

qrvd added 2 commits October 18, 2025 22:43
It was never used, and removing it simplifies the function.
(but honestly the pylint error forced my hand here)
@qrvd qrvd force-pushed the nesting-issue-1925 branch 2 times, most recently from 2619873 to b6e7eb0 Compare October 18, 2025 21:28
Copy link
Member

@toonn toonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of dropping functionality for the sake of appeasing the linter. I'm also not sure that some plugin doesn't depend on this so I'd prefer to leave it in. It also seems like we could use ignore to tackle this problem, no?

How does this handle a directory name that occurs multiple times throughout the directory trees involved?

What does upstream copytree do in this case, create a recursively nested structure like we do or do they handle it better?

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.

2 participants