-
-
Notifications
You must be signed in to change notification settings - Fork 76
Cache mirror list #475
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
base: master
Are you sure you want to change the base?
Cache mirror list #475
Conversation
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 <[email protected]>
Even better, thanks! |
This enables zig.install to work even if ziglang.org is down.
I meant to do this as a follow up to #438 but then forgot about it.