Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,23 @@ async function downloadTarball(tarball_filename) {
return await downloadFromMirror(preferred_mirror, tarball_filename);
}

// Fetch the list of mirrors from ziglang.org. Caching the mirror list is awkward in this context,
// so if the list is inaccessible, we just fetch from ziglang.org as a fallback.
let mirrors = [];
try {
// Fetch the list of mirrors from ziglang.org.
const mirrors_response = await fetch(MIRRORS_URL);
mirrors = (await mirrors_response.text()).split('\n').filter((url) => url.length != 0);
} catch {
// For some reason the mirrors are inaccessible. That's okay; allow ourselves to fall back to ziglang.org below.
// ziglang.org itself is down. Use this backup list instead.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I wonder why we don't upload the mirror file to GitHub?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to avoid the parsing overhead. it's not a long list to make an array

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that this array is hardcoded, which I don't think is a good practice.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it being hardcoded here is the whole point of this patch

// Update this periodically to keep it in sync with the upstream community mirror list.
mirrors = [
"https://pkg.machengine.org/zig",
"https://zigmirror.hryx.net/zig",
"https://zig.linus.dev/zig",
"https://zig.squirl.dev",
"https://zig.florent.dev",
"https://zig.mirror.mschae23.de/zig",
"https://zigmirror.meox.dev",
];
}

core.info(`Available mirrors: ${mirrors.join(", ")}`);
Expand Down