-
-
Notifications
You must be signed in to change notification settings - Fork 154
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
Add aiofiles.os.symlink function #124
Conversation
tests/test_os.py
Outdated
initial_src_nlink = stat(src_filename).st_nlink | ||
await aiofiles.os.link(src_filename, dst_filename) | ||
assert ( | ||
exists(src_filename) and | ||
exists(dst_filename) and | ||
stat(src_filename).st_ino == stat(dst_filename).st_ino | ||
exists(src_filename) | ||
and exists(dst_filename) | ||
and (stat(src_filename).st_ino == stat(dst_filename).st_ino) | ||
and (stat(src_filename).st_nlink == initial_src_nlink + 1)( | ||
stat(dst_filename).st_nlink == 2 | ||
) | ||
) | ||
await aiofiles.os.remove(dst_filename) | ||
assert exists(src_filename) and exists(dst_filename) is False | ||
assert ( | ||
exists(src_filename) | ||
and exists(dst_filename) is False | ||
and (stat(src_filename).st_nlink == initial_src_nlink) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the aiofiles.os.link
test to better show the difference between symlinks and hardlinks:
- Symlinks: Share the same inode (
st_ino
). - Hardlinks: Share the same inode (
st_ino
) AND have their link counter (st_nlink
) incremented.
Codecov Report
@@ Coverage Diff @@
## master #124 +/- ##
==========================================
+ Coverage 89.66% 89.70% +0.03%
==========================================
Files 10 10
Lines 300 301 +1
==========================================
+ Hits 269 270 +1
Misses 31 31
Continue to review full report at Codecov.
|
You're on quite a roll! Thanks. |
The
os
module in the stdlib provides a function calledos.symlink
that creates a symlink to the src file. This PR adds the async version of that.Docs: https://docs.python.org/3/library/os.html#os.symlink
I've added the relevant unit test in test_os.py, plus updated the
aiofiles.os.link
test to better differentiate the two.