jborean93 / smbprotocol

Python SMBv2 and v3 Client
MIT License
309 stars 72 forks source link

Add smb_info to a scandir result #251

Closed jborean93 closed 7 months ago

jborean93 commented 7 months ago

Adds the property smb_info to the scandir enumerated result which contains the already retrieved metadata on the file during the scan operation. This provides a more efficient way for callers to retrieve information like the file times, sizes, attributes straight away without having to call .stat() which results in another SMB request to the server.

Fixes: https://github.com/jborean93/smbprotocol/issues/250

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (eaf24fa) 99.05% compared to head (1d3c6b5) 99.06%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #251 +/- ## ======================================= Coverage 99.05% 99.06% ======================================= Files 24 24 Lines 5097 5112 +15 ======================================= + Hits 5049 5064 +15 Misses 48 48 ``` | [Flag](https://app.codecov.io/gh/jborean93/smbprotocol/pull/251/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | Coverage Δ | | |---|---|---| | [](https://app.codecov.io/gh/jborean93/smbprotocol/pull/251/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | `99.06% <100.00%> (+<0.01%)` | :arrow_up: | | [py3.10](https://app.codecov.io/gh/jborean93/smbprotocol/pull/251/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | `99.02% <100.00%> (+<0.01%)` | :arrow_up: | | [py3.11](https://app.codecov.io/gh/jborean93/smbprotocol/pull/251/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | `99.02% <100.00%> (+<0.01%)` | :arrow_up: | | [py3.12](https://app.codecov.io/gh/jborean93/smbprotocol/pull/251/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | `99.02% <100.00%> (+<0.01%)` | :arrow_up: | | [py3.7](https://app.codecov.io/gh/jborean93/smbprotocol/pull/251/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | `99.01% <100.00%> (+<0.01%)` | :arrow_up: | | [py3.8](https://app.codecov.io/gh/jborean93/smbprotocol/pull/251/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | `99.02% <100.00%> (+<0.01%)` | :arrow_up: | | [py3.9](https://app.codecov.io/gh/jborean93/smbprotocol/pull/251/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | `99.05% <100.00%> (+<0.01%)` | :arrow_up: | | [x64](https://app.codecov.io/gh/jborean93/smbprotocol/pull/251/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | `99.06% <100.00%> (+<0.01%)` | :arrow_up: | | [x86](https://app.codecov.io/gh/jborean93/smbprotocol/pull/251/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean) | `98.98% <100.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jordan+Borean#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

rikroe commented 7 months ago

Thank you so much!

I was hoping you'd be fine with using the data and wanted to ask to create a PR for that, but you have been blazing fast!

I tested your PR code, it is working smoothly! And even faster on large files than ls -Al on a cifs mount 🔥 (~4:30min against ~10min for 280k files).

jborean93 commented 7 months ago

I was hoping you'd be fine with using the data and wanted to ask to create a PR for that, but you have been blazing fast!

You just picked the right time to open the issue, I've been neglecting this library for a while now and needed to get back to it.

I tested your PR code, it is working smoothly! And even faster on large files than ls -Al on a cifs mount 🔥 (~4:30min against ~10min for 280k files).

Thanks for testing, I'm actually surprised it's faster than a cifs mount but always happen to see that there are some benefits here :)