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

Add download functionality to ulwgl_run #30

Merged
merged 36 commits into from
Feb 18, 2024

Conversation

R1kaB3rN
Copy link
Member

@R1kaB3rN R1kaB3rN commented Feb 15, 2024

Closes #29 and #16

With the current rewrite, when the user does not specify the $PROTONPATH, no download of the latest Proton is made on their behalf and this PR aims add that same functionality.

When no Proton is specified, we only attempt to download the latest Proton if a Proton cannot be found in the Steam compat tools directory. Otherwise, referring to $HOME/.cache/ULWGL if something wrong happens when downloading or if the user is offline.

Concretely the order is:

Steam compat -> Cache -> Download -> Cache

Effectively, new installations will always download the latest Proton, while existing ones will simply be warned to the console of a later version. Downloading is avoided if the latest version already exists in the cache, and the cache will be used as a last resort (e.g. download fails, digest mismatch, etc.) to set the variable. When we're unable to find an existing Proton or download one, we simply terminate the script as we there's no point using it without specifying Proton.

TODO:

  • Change GE-Proton -> ULWGL-Proton
  • Add tests

- When the user does not specify the PROTONPATH, attempt to download the latest Proton if Proton cannot be found in either the Steam compat tools or local cache. Otherwise, prioritize referring to existing ones -- $HOME/.local/share/Steam/compatibilitytools.d and $HOME/.cache/ULWGL.

- Effectively, new installations will always download the latest Proton, while existing ones will simply be warned of a later version. Downloading is avoided if the latest version already exists in the cache, and the cache will be used as a last resort to set the variable. When we're unable to find an existing Proton or download one, we raise an error.
- Add missing return statement

- Delete property access of name
- When we're downloading the latest Proton, it's possible the user can interrupt download or extraction process which can lead to corrupted or incomplete files. As a result, in the next run of the launcher, a FileNotFoundError can be falsely raised for the $PROTONPATH/proton file. In the case of an interrupt, be sure to remove the relevant files before we exit.
- When extracting from the cache to the compatibilitytools.d directory, be sure to remove the leftover data after the interrupt to avoid future errors.
- Code block in which the digest mismatched, user interrupt or failure to download/no internet.
- Update the check_env tests for new usage when PROTONPATH is not set by mocking the callout.
- Referencing the tuple element within the array for the tarball name then parsing it was becoming highly error prone/unreadable.
- Prefer a shorter message when download fails or Proton cannot be found, and reference ULWGL-Proton Github repository instead of GE-Proton
- Arguably the most important test of this test suite as we do **not** want to remove files that isn't ours. We test both the positive and negative case. In the latter, the state of the cache or Steam compat should be left the same state as it was before executing the function when passed files that do not exist.
- Creates more test files within the compat/cache directories to verify that there wasn't any side effects after executing _cleanup
- Fixes a logic error by terminating prematurely when referencing an old Proton version that has been saved in the cache
@R1kaB3rN R1kaB3rN marked this pull request as ready for review February 18, 2024 03:08
@GloriousEggroll
Copy link
Member

LGTM!

@GloriousEggroll GloriousEggroll merged commit b034600 into Open-Wine-Components:main Feb 18, 2024
2 checks passed
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.

Missing auto download of proton in python rewrite
2 participants