summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2025-02-13 22:19:07 +0100
committerDavid Lönnhager <david.l@mullvad.net>2025-03-05 23:32:04 +0100
commit5519974065256f866c22102d44ef72d9c7e98030 (patch)
tree3eed8d81dad94837e666a7235921d7fcee5634ab
parent25e5ee878516830c559dfea1314d1ad1f7bdef3f (diff)
downloadmullvadvpn-5519974065256f866c22102d44ef72d9c7e98030.tar.xz
mullvadvpn-5519974065256f866c22102d44ef72d9c7e98030.zip
Remove installer if verification fails
-rw-r--r--mullvad-update/src/app.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/mullvad-update/src/app.rs b/mullvad-update/src/app.rs
index b693520bf1..6d1f6b8198 100644
--- a/mullvad-update/src/app.rs
+++ b/mullvad-update/src/app.rs
@@ -98,9 +98,20 @@ impl<AppProgress: ProgressUpdater> AppDownloader for HttpAppDownloader<AppProgre
async fn verify(&mut self) -> Result<(), DownloadError> {
let bin_path = self.bin_path().expect("Performed after 'create_cache_dir'");
let hash = self.hash_sha256();
- Sha256Verifier::verify(bin_path, *hash)
+
+ match Sha256Verifier::verify(&bin_path, *hash)
.await
.map_err(DownloadError::Verification)
+ {
+ // Verification succeeded
+ Ok(()) => Ok(()),
+ // Verification failed
+ Err(err) => {
+ // Attempt to clean up
+ let _ = tokio::fs::remove_file(bin_path).await;
+ Err(err)
+ }
+ }
}
async fn install(&mut self) -> Result<(), DownloadError> {