-
Notifications
You must be signed in to change notification settings - Fork 454
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
Modify check_free_space function
to verify available disk space
#7760
Conversation
logger.info('Check free space') | ||
def check_free_space(state_dir: Path): | ||
""" Check if there is enough free space on the disk.""" | ||
logger.info(f'Checking free space for the folder: {state_dir}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: Using f-strings in logging calls is generally discouraged (see for example https://pylint.readthedocs.io/en/stable/user_guide/messages/warning/logging-fstring-interpolation.html).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had this discussion before: #5611 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I forgot about that. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the suggestion. For this PR, I left the "f-string" version, but we can discuss it at the next dev meeting. In case of an altered agreement, I'll change the formatting for all upcoming pull requests.
This commit modifies the function `check_free_space`. The function checks if there is enough free space on the disk by calculating the disk usage of a specified folder. If the available space is less than 100MB, an error message is displayed and Tribler exits. The function also logs the amount of free space when it is sufficient. Additionally, in the `start_gui.py` module, the `check_free_space` function now takes a parameter specifying the root state directory to be checked for free space. Add test cases for check_free_space - Added new test cases for the `check_free_space` function to ensure it works correctly when there's sufficient disk space and raises an exception when there's insufficient disk space. - Also added test cases to check the behavior when there's an ImportError or OSError.
…le disk space This commit modifies the function `check_free_space`. The function checks if there is enough free space on the disk by calculating the disk usage of a specified folder. If the available space is less than 100MB, an error message is displayed and Tribler exits. The function also logs the amount of free space when it is sufficient. Additionally, in the `start_gui.py` module, the `check_free_space` function now takes a parameter specifying the root state directory to be checked for free space. Add test cases for check_free_space - Added new test cases for the `check_free_space` function to ensure it works correctly when there's sufficient disk space and raises an exception when there's insufficient disk space. - Also added test cases to check the behavior when there's an ImportError or OSError. (cherry picked from commit b2bc372)
This PR modifies the function
check_free_space
to ignoreOSErrors
so they cannot lead to Tribler crashing.Additionally, in the
start_gui.py
module, thecheck_free_space
function now takes a parameter specifying the root state directory to be checked for free space.Fixes #7745