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

Set insufficient storage DeviceStatus in ContentSyncHook.post_transfer #11255

Conversation

nucleogenesis
Copy link
Member

Summary

Moves the logic that calculates the total size of incomplete downloads from the request processing method into its own class.

That class then is imported to and used in ContentSyncHook.post_transfer to set the DeviceStatus to InsufficientStorage whenever there is not enough space available for the sync.

References

Fixes #10382

Reviewer guidance

Do we need to unset this when there is enough space or anything like that?

Thoughts on test coverage would be appreciated. I pulled in and used some existing test classes to do the data setup for me. @rtibbles and I discussed a test case for the StorageCalculator class but it is kind of covered by way of the many integration tests using the _process_content_requests which repeatedly instantiate, use and rely on StorageCalculator.

@nucleogenesis nucleogenesis added the TODO: needs review Waiting for review label Sep 15, 2023
@github-actions github-actions bot added DEV: backend Python, databases, networking, filesystem... SIZE: medium labels Sep 15, 2023
kolibri/core/content/utils/content_request.py Outdated Show resolved Hide resolved
kolibri/core/content/kolibri_plugin.py Outdated Show resolved Hide resolved
Copy link
Member

@bjester bjester left a comment

Choose a reason for hiding this comment

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

LGTM!

self._create_resources(self.admin_request.contentnode_id)
mock_hook.post_transfer = lambda *args: ContentSyncHook.post_transfer(
mock_hook, *args
)
Copy link
Member

Choose a reason for hiding this comment

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

Looks like python2.7 tests are failing on this test. There shouldn't be any harm AFAIK in creating an instance of the ContentSyncHook so you could try to remove the mocking.

@nucleogenesis nucleogenesis merged commit 2384ae1 into learningequality:release-v0.16.x Sep 21, 2023
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem... SIZE: medium TODO: needs review Waiting for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement calculation and pre-determination of insufficient storage status
2 participants