jborean93 / smbprotocol

Python SMBv2 and v3 Client
MIT License
318 stars 73 forks source link

Make scandir accept a local path #100

Closed dHannasch closed 3 years ago

dHannasch commented 3 years ago

This is built atop https://github.com/jborean93/smbprotocol/pull/99; look there first.

For https://github.com/jborean93/smbprotocol/blob/master/smbclient/shutil.py#L316.

Together with the others, this allows copytree to copy from a local directory as well.

codecov[bot] commented 3 years ago

Codecov Report

Merging #100 (5c943bd) into master (9f6aa48) will increase coverage by 0.04%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #100      +/-   ##
==========================================
+ Coverage   98.57%   98.61%   +0.04%     
==========================================
  Files          23       23              
  Lines        4981     4983       +2     
==========================================
+ Hits         4910     4914       +4     
+ Misses         71       69       -2     
Impacted Files Coverage Δ
smbclient/shutil.py 91.85% <100.00%> (+0.15%) :arrow_up:
smbprotocol/transport.py 100.00% <0.00%> (+2.17%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9f6aa48...5c943bd. Read the comment docs.

jborean93 commented 3 years ago

Sorry I started looking at your PRs and I got a bit sidetracked. Currently all the functions in smbclient/_os.py are purely for the SMB operations and I've tried to keep them separate from the shutil functions which is designed to give a filesystem agnostic/more human friendly layer over the top. If the end goal is to implement copytree with a local dir then these changes should occur in copytree itself.

This is similar to copyfile where _os.copyfile is strictly to copy a file across the same SMB share (a specific operation in SMB). Compare that to shutil.copyfile which detects whether it should use the os copyfile or whether it needs to do a mixture of commands when the files aren't on the same SMB share.

Another benefit is that you can just implement that specific functionality purely for Python 3 which has the native scandir operation. Consider I am planning on dropping 2.7 at some point soon I don't see the harm in that particular feature being restricted to 3+ right now.

jborean93 commented 3 years ago

See https://github.com/jborean93/smbprotocol/pull/107#issuecomment-887350202