Repository navigation
Keep directories holding deeper files in a recursive MemoryFileSystem.rm with maxdepth - #2244
Merged
Merged
Conversation
….rm with maxdepth expand_path stops at maxdepth, so a directory at the last level can still hold files below it, and rmdir raised OSError for it. Skip such directories, as LocalFileSystem.rm does.
Contributor
Author
|
The pytest-win failures are the three |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MemoryFileSystem.rm(path, recursive=True, maxdepth=...)raises when a directory at the last expanded level still holds files belowmaxdepth:Without the
mkdir(implicit directories) it raisesFileNotFoundError: /src/sub/deeperinstead.expand_pathstops atmaxdepth, so/src/sub/deeperis in the list butlow.txtis not, andrmdirrefuses the non-empty directory. Before raising it has already deletedtop.txtandmid.txt.#2238 made
LocalFileSystem.rmkeep a directory that still holds deeper files in this case. This does the same for the memory filesystem: whenmaxdepthis given, a directory that is not empty after the files above it are removed is kept. Withoutmaxdepth, or for a non-recursivermof a non-empty directory, nothing changes.Tests: added
test_rm_recursive_maxdepth_keeps_deeper_filestotest_memory.py(with implicit and explicit directories), mirroring the local test. Both cases fail on master and pass here.test_memory.pyand the memory abstract tests pass, and ruff/codespell are clean. Added a changelog entry.