-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
feat(bundler): add TAURI_BUNDLER_TOOLS_GITHUB_MIRROR
to specify a GitHub mirror
#10866
Conversation
…ler to support GitHub CDN This commit introduces a feature that checks for the presence of an environment variable `GITHUB_CDN` before downloading the webview2 offline installer. If `GITHUB_CDN` is set, the download URL is rewritten to use a specified GitHub CDN, which can improve download speeds for users in regions where direct access to GitHub might be slow or unreliable. This change allows users to benefit from faster downloads without needing to configure proxy servers, particularly beneficial for those in mainland China where alternative CDNs are commonly used.
Package Changes Through 1c42375There are 2 changes which include tauri-bundler with prerelease, tauri-cli with prerelease Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
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, could you also add a change file in .changes
directory?
@@ -70,8 +70,20 @@ pub fn download_webview2_offline_installer(base_path: &Path, arch: &str) -> crat | |||
pub fn download(url: &str) -> crate::Result<Vec<u8>> { | |||
log::info!(action = "Downloading"; "{}", url); | |||
|
|||
let agent = ureq::AgentBuilder::new().try_proxy_from_env(true).build(); | |||
let response = agent.get(url).call().map_err(Box::new)?; | |||
let (agent, url) = match std::env::var("GITHUB_CDN") { |
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.
I think GITHUB_CDN
is a bit vague, maybe TAURI_BUNDLER_TOOLS_DOWNLOAD_HOST
is better here. You also need to document that env var in crates/tauri-cli/ENVIRONEMENT_VARIABLES.md
file
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.
Currently, tauri-bundler downloads files from GitHub, which is why the variable name GITHUB_CDN
is used.
If future versions source downloads from other websites, the variable TAURI_BUNDLER_TOOLS_DOWNLOAD_HOST
might cause confusion or errors. To avoid this, would it be more appropriate to rename it to TAURI_BUNDLER_TOOLS_DOWNLOAD_GITHUB_CDN
or TAURI_BUNDLER_TOOLS_DOWNLOAD_GITHUB_TEMPLATE
?
Or is it unlikely that future versions of tauri-bundler will download files from any site other than GitHub?
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.
webview2, which this pr is about, isn't downloaded from github though?
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.
In accordance with internet regulations, users in mainland China are unable to directly download files from GitHub. A proxy is typically required. However, some users are not proficient in using proxies. Hence, I desire to add this feature—to facilitate file downloads from GitHub via public reverse proxy servers (CDN).
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.
Yes, i understood this. I am not against this PR/change. I'm just saying that the GITHUB_CDN variable is used here for files that are not downloaded from github but from microsoft.
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.
I understand what you mean now, so I should add a source check, prioritizing CDN usage for files coming from GitHub, and for files from other source websites, downloading them based on try_proxy_from_env
.
- Renamed the `GITHUB_CDN` environment variable to `TAURI_BUNDLER_TOOLS_DOWNLOAD_GITHUB_CDN` for clarity. - Added error handling for URL parsing in the Windows-specific utility functions. - Updated documentation to reflect the new environment variable.
- Extracted the creation of the HTTP agent and URL into a separate function `create_agent_and_url`. - Ensured that the `TAURI_BUNDLER_TOOLS_DOWNLOAD_GITHUB_CDN` environment variable is used when downloading from GitHub CDN.
Co-authored-by: Amr Bashir <github@amrbashir.me>
Co-authored-by: Amr Bashir <github@amrbashir.me>
Co-authored-by: Amr Bashir <github@amrbashir.me>
Co-authored-by: Amr Bashir <github@amrbashir.me>
TAURI_BUNDLER_TOOLS_GITHUB_MIRROR
to specify a GitHub mirror
This feature is designed to facilitate the use of
tauri
for developers in Mainland China or other regions where GitHub is not accessible.This commit introduces a feature that checks for the presence of an environment variable
TAURI_BUNDLER_TOOLS_GITHUB_MIRROR
before downloading the webview2 offline installer. IfTAURI_BUNDLER_TOOLS_GITHUB_MIRROR
is set, the download URL is rewritten to use a specified GitHub mirror, which can improve download speeds for users in regions where direct access to GitHub might be slow or unreliable. This change allows users to benefit from faster downloads without needing to configure proxy servers, particularly beneficial for those in mainland China where alternative mirrors are commonly used.This commit helps resolve the issue encountered in #7338.
PowerShell: