Skip to content

Commit df380e3

Browse files
committed
Fall back to using GitHub releases of libsodium if the download site is unavailable
1 parent 815fb5d commit df380e3

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

project/settings/package.mill.scala

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,29 @@ trait CliLaunchers extends SbtModule { self =>
233233
os.copy.over(libPath, destDir / s"${prefix}sodiumjni.$ext")
234234
}
235235
private def copyLibsodiumStaticTo(cs: String, destDir: os.Path, workspace: os.Path): Unit = {
236-
val dirRes = os.proc(
237-
cs,
238-
"get",
239-
"--archive",
240-
s"https://download.libsodium.org/libsodium/releases/libsodium-$libsodiumVersion-stable-msvc.zip"
241-
).call()
236+
val dirRes = {
237+
val stable = os.proc(
238+
cs,
239+
"get",
240+
"--archive",
241+
s"https://download.libsodium.org/libsodium/releases/libsodium-$libsodiumVersion-stable-msvc.zip"
242+
).call(check = false)
243+
if (stable.exitCode == 0) stable
244+
else {
245+
System.err.println(
246+
s"Failed to download stable libsodium $libsodiumVersion from https://download.libsodium.org/libsodium/releases"
247+
)
248+
System.err.println(
249+
"falling back to https://github.com/jedisct1/libsodium/releases *-RELEASE"
250+
)
251+
os.proc( // fallback to GitHuB *-RELEASE version
252+
cs,
253+
"get",
254+
"--archive",
255+
s"https://github.com/jedisct1/libsodium/releases/download/$libsodiumVersion-RELEASE/libsodium-$libsodiumVersion-msvc.zip"
256+
).call()
257+
}
258+
}
242259
val dir = os.Path(dirRes.out.trim(), workspace)
243260
os.copy.over(
244261
dir / "libsodium" / "x64" / "Release" / "v143" / "static" / "libsodium.lib",

0 commit comments

Comments
 (0)