modoboa / modoboa-installer

An installer for Modoboa
MIT License
254 stars 135 forks source link

Automx fix #525

Open fbfeix opened 10 months ago

fbfeix commented 10 months ago

Description of the issue/feature this PR addresses: The _setup_venv method in the existing codebase has been experiencing intermittent SSL connection issues when attempting to download a file using wget. This problem has been causing the method to fail occasionally, preventing the successful setup of a virtual environment. Additionally, the method assumes the downloaded archive will be located in a certain directory without verifying the file's existence, leading to potential errors during the unzipping process.

Current behavior before PR:

  1. The _setup_venv method uses wget to download a file, but if an SSL connection issue occurs, the method fails without retrying the download.
  2. The method assumes the downloaded file will be located in a specific directory and proceeds to attempt unzipping the file without verifying its existence, which could lead to a failure if the file is not found.

Desired behavior after PR is merged:

  1. A new method download_remote_file has been introduced to handle file downloads, with the capability to retry the download a specified number of times in case of failures, mitigating the impact of intermittent SSL connection issues.
  2. The _setup_venv method now utilizes the download_remote_file method to handle the file download, ensuring that the file exists before proceeding to unzip it.
  3. The download_remote_file method ensures the target directory exists or creates it if necessary, and returns the absolute path of the downloaded file, providing more robust file handling and aiding in troubleshooting if issues arise in the future.
codecov[bot] commented 10 months ago

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (4a2e9f2) 54.40% compared to head (5aae454) 53.73%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #525 +/- ## ========================================== - Coverage 54.40% 53.73% -0.67% ========================================== Files 10 10 Lines 761 776 +15 ========================================== + Hits 414 417 +3 - Misses 347 359 +12 ``` | [Files](https://app.codecov.io/gh/modoboa/modoboa-installer/pull/525?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=modoboa) | Coverage Δ | | |---|---|---| | [modoboa\_installer/utils.py](https://app.codecov.io/gh/modoboa/modoboa-installer/pull/525?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=modoboa#diff-bW9kb2JvYV9pbnN0YWxsZXIvdXRpbHMucHk=) | `54.48% <20.00%> (-1.75%)` | :arrow_down: |

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