Skip to content
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

Support for st_blocks field #722

Closed
albrycht opened this issue Sep 30, 2022 · 4 comments · Fixed by #725
Closed

Support for st_blocks field #722

albrycht opened this issue Sep 30, 2022 · 4 comments · Fixed by #725

Comments

@albrycht
Copy link

albrycht commented Sep 30, 2022

Is your feature request related to a problem? Please describe.
I have a code that crawls filesystem. One of most important field that I read from stat is st_blocks (see: https://docs.python.org/3/library/os.html#os.stat_result.st_blocks)
Without that field my code fails with: AttributeError: 'FakeStatResult' object has no attribute 'st_blocks'

I know that theoretically, it doesn't have to be there but I haven't met POSIX filesystem that wouldn't have that field yet.

Describe the solution you'd like
Add st_blocks field to FakeStatResult.

Describe alternatives you've considered
The only alternative I see right now is not to use pyfakefs and mock os calls by myself.

@mrbean-bremen
Copy link
Member

I guess it would be enough if the result would just be something like st_size / 512 + 1?

@albrycht
Copy link
Author

Result should be int so I would suggest st_size // 512 + 1.

@mrbean-bremen
Copy link
Member

Of course, that was what I meant - ok, I will see what I can do, maybe I will get to it over the weekend.

mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Oct 2, 2022
mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Oct 2, 2022
mrbean-bremen added a commit that referenced this issue Oct 2, 2022
@mrbean-bremen
Copy link
Member

Implemented in master now - please check!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants