Move checksum check a bit above

It's pointless to let user waste bandwidth on the full ASF asset if checksum is not available right away
This commit is contained in:
Archi
2021-11-23 11:58:12 +01:00
parent 8b0e71e72d
commit b64ad59eff
3 changed files with 25 additions and 14 deletions

View File

@@ -266,6 +266,21 @@ public static class ASF {
return null;
}
ArchiLogger.LogGenericInfo(Strings.FetchingChecksumFromRemoteServer);
string? remoteChecksum = await ArchiNet.FetchBuildChecksum(newVersion, SharedInfo.BuildInfo.Variant).ConfigureAwait(false);
switch (remoteChecksum) {
case null:
// Timeout or error, refuse to update as a security measure
return null;
case "":
// Unknown checksum, release too new or actual malicious build published, no need to scare the user as it's 99.99% the first
ArchiLogger.LogGenericWarning(Strings.ChecksumMissing);
return SharedInfo.Version;
}
if (!string.IsNullOrEmpty(releaseResponse.ChangelogPlainText)) {
ArchiLogger.LogGenericInfo(releaseResponse.ChangelogPlainText!);
}
@@ -290,19 +305,6 @@ public static class ASF {
ArchiLogger.LogGenericInfo(Strings.VerifyingChecksumWithRemoteServer);
string? remoteChecksum = await ArchiNet.FetchBuildChecksum(newVersion, SharedInfo.BuildInfo.Variant).ConfigureAwait(false);
switch (remoteChecksum) {
case null:
// Timeout or error, refuse to update as a security measure
return null;
case "":
// Unknown checksum, release too new or actual malicious build published, no need to scare the user as it's 99.99% the first
ArchiLogger.LogGenericWarning(Strings.ChecksumMissing);
return SharedInfo.Version;
}
byte[] responseBytes = response.Content as byte[] ?? response.Content.ToArray();
string checksum = Convert.ToHexString(SHA512.HashData(responseBytes));