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

fix: improve cache invalidation in MockDirectoryInfo #862

Merged
merged 2 commits into from
Jul 19, 2022

Conversation

rcdailey
Copy link
Contributor

When invoking the Create() and Delete() methods on
MockDirectoryInfo, the Exists property should intrinsically invoke
Refresh() the next time it is called. This is necessary to prevent
returning stale state about the directory after those operations.

Additional test cases have been added for MoveTo() as well, to ensure
it also not returning stale state.

For context, this change was motivated by PR #828 where similar issues
were solved in MockFileInfo.

@rcdailey
Copy link
Contributor Author

I'm not going to add the conventional commit prefix as I prefer the repository maintainers to squash-merge my PR and apply the appropriate convention. This is not out of laziness, but rather out of respect: The maintainers will be more familiar with how they wish to deliver my changes.

Copy link
Contributor

@fgreinacher fgreinacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @rcdailey! We have a failing test on non-Windows that needs adaptation, otherwise good to go!

When invoking the `Create()` and `Delete()` methods on
`MockDirectoryInfo`, the `Exists` property should intrinsically invoke
`Refresh()` the next time it is called. This is necessary to prevent
returning stale state about the directory after those operations.

Additional test cases have been added for `MoveTo()` as well, to ensure
it also not returning stale state.

For context, this change was motivated by PR TestableIO#828 where similar issues
were solved in `MockFileInfo`.
@rcdailey rcdailey force-pushed the directory-info-better-refresh branch from ae2e5b3 to 18d37a8 Compare July 11, 2022 21:27
@rcdailey
Copy link
Contributor Author

@fgreinacher Let me know if there's anything else I need to do. Thank you once again for taking the time to review my PR.

@fgreinacher fgreinacher changed the title Better cache invalidation in MockDirectoryInfo fix: improve cache invalidation in MockDirectoryInfo Jul 19, 2022
@fgreinacher fgreinacher self-requested a review July 19, 2022 17:51
Copy link
Contributor

@fgreinacher fgreinacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work on this!

@mergify mergify bot merged commit 2c267dc into TestableIO:main Jul 19, 2022
fgreinacher added a commit that referenced this pull request Jul 19, 2022
When invoking the `Create()` and `Delete()` methods on
`MockDirectoryInfo`, the `Exists` property should intrinsically invoke
`Refresh()` the next time it is called. This is necessary to prevent
returning stale state about the directory after those operations.

Additional test cases have been added for `MoveTo()` as well, to ensure
it also not returning stale state.

For context, this change was motivated by PR #828 where similar issues
were solved in `MockFileInfo`.

Co-authored-by: Florian Greinacher <florian@greinacher.de>
@rcdailey rcdailey deleted the directory-info-better-refresh branch November 23, 2022 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants