Repository navigation
Conversation
Added validation to ensure destination is not a directory.
Author
|
Could a maintainer please review the fix for #496 and approve the pending GitHub Actions run? AppVeyor is passing. Thanks. |
This branch has not been deployed
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.
Type of changes
Description
Fixes #496.
Problem
OSFS.copy(..., overwrite=True)can treat a directory destination as a container. The same-instancecopy_filepath can then overwrite a same-named file inside that directory instead of rejecting the destination.Fix
Reject directory destinations in
_check_copywithFileExpected, before either copy implementation runs. Existing source checks,DestinationExistswhen overwrite is disabled, and same-path checks keep their current order.Tests
copy_file, directory symlinks, root destinations and error precedence. The new tests fail on the unchanged source and pass with the fix.Process.net_connectionswith psutil 5.9.8.git diff --checkpass.Limitations
Tested on Linux with Python 3.10. Legacy sendfile/fallback method source was checked on that runtime, not on an older interpreter. Windows and macOS were not tested. This validation check does not make copying atomic or protect against external filesystem changes after validation.
Checklist