This repository was archived by the owner on Nov 25, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 76
Cache mirror list #475
Merged
Merged
Cache mirror list #475
+63
−37
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Techatrix
suggested changes
Nov 15, 2025
Collaborator
Techatrix
left a comment
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.
The mirror fetching could also be made lazy to further reduce requests made for community-mirrors.txt.
This may also make it viable to report a message to the user if we failed to fetch the mirror list.
diff --git a/src/versionManager.ts b/src/versionManager.ts
index 3e595e7..14d1643 100644
--- a/src/versionManager.ts
+++ b/src/versionManager.ts
@@ -36,7 +36,7 @@ export interface Config {
* `"version"` for Zig, `"--version"` for ZLS
*/
versionArg: string;
- mirrorUrls: vscode.Uri[];
+ getMirrorUrls: () => Promise<vscode.Uri[]>;
canonicalUrl: {
release: vscode.Uri;
nightly: vscode.Uri;
@@ -93,7 +93,7 @@ async function installGuarded(config: Config, version: semver.SemVer): Promise<s
throw new Error(`Can't install ${config.title} because 'tar' could not be found`);
}
- const mirrors = [...config.mirrorUrls]
+ const mirrors = [...(await config.getMirrorUrls())]
.map((mirror) => ({ mirror, sort: Math.random() }))
.sort((a, b) => a.sort - b.sort)
.map(({ mirror }) => mirror);
diff --git a/src/zigSetup.ts b/src/zigSetup.ts
index 6c6e7ad..e8d5021 100644
--- a/src/zigSetup.ts
+++ b/src/zigSetup.ts
@@ -713,7 +713,9 @@ export async function setupZig(context: vscode.ExtensionContext) {
/** https://ziglang.org/download */
minisignKey: minisign.parseKey("RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U"),
versionArg: "version",
- mirrorUrls: await getMirrors(context),
+ getMirrorUrls() {
+ return getMirrors(context);
+ },
canonicalUrl: {
release: vscode.Uri.parse("https://ziglang.org/download"),
nightly: vscode.Uri.parse("https://ziglang.org/builds"),
diff --git a/src/zls.ts b/src/zls.ts
index 0a72eb2..0bdc3b6 100644
--- a/src/zls.ts
+++ b/src/zls.ts
@@ -511,7 +511,9 @@ export async function activate(context: vscode.ExtensionContext) {
/** https://github.com/zigtools/release-worker */
minisignKey: minisign.parseKey("RWR+9B91GBZ0zOjh6Lr17+zKf5BoSuFvrx2xSeDE57uIYvnKBGmMjOex"),
versionArg: "--version",
- mirrorUrls: [],
+ getMirrorUrls() {
+ return Promise.resolve([]);
+ },
canonicalUrl: {
release: vscode.Uri.parse("https://builds.zigtools.org"),
nightly: vscode.Uri.parse("https://builds.zigtools.org"),
Co-authored-by: Techatrix <techatrix@mailbox.org>
Member
Author
Even better, thanks! |
Techatrix
approved these changes
Nov 15, 2025
This enables zig.install to work even if ziglang.org is down.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I meant to do this as a follow up to #438 but then forgot about it.