mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
fix: third-party GitHub mirrors only serve downloads with a trusted digest (#1057)
fix: a third-party GitHub mirror can only serve downloads that carry a trusted digest Downloads without an expected SHA-256 were still sent through gh-proxy, ghfast and other mirrors, and the first answer was accepted, so a mirror could swap an AppImage or a Windows component. Downloader.downloadFile now tries only the original URL when there is no digest. UserApps passes GitHub's own asset digest, and WinComponents passes the snapshot's archive digest, so those large files keep their mirror fallback. Co-authored-by: ovurrsl <ovurrsl@users.noreply.github.com> Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
This commit is contained in:
1 parent
d9328c39df
commit
87e4b42ed8
4 files changed
+23
-6
No files matched your search
@@ -369,7 +369,9 @@ object WinComponents {
|
||||
val archiveName = archive.optString("name")
|
||||
val url = c.snapshot.substringBeforeLast('/') + "/" + archiveName
|
||||
val file = File(work, "${c.name}.files.tar.xz")
|
||||
if (!Downloader.downloadFile(url, file, false) { f -> onProgress(Progress(c.name, archiveName, Phase.DOWNLOAD, if (f < 0) -1 else Math.round(f * 100f))) }) {
|
||||
// The snapshot came straight from github.com, so its digest may vouch for a mirror's copy of the archive.
|
||||
val sha = archive.optString("sha256").takeIf { it.matches(Regex("(?i)[0-9a-f]{64}")) }
|
||||
if (!Downloader.downloadFile(url, file, false, sha) { f -> onProgress(Progress(c.name, archiveName, Phase.DOWNLOAD, if (f < 0) -1 else Math.round(f * 100f))) }) {
|
||||
return null to "download failed: $archiveName"
|
||||
}
|
||||
archive.optString("sha256").takeIf { it.length == 64 }?.let { sha ->
|
||||
|
||||
Reference in new issue
Block a user