Skip to content

Commit fe57493

Browse files
committed
Fallback to using GitHub releases of libsodium if the download site is unavailable
1 parent 72988e3 commit fe57493

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

project/settings.sc

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

0 commit comments

Comments
 (0)