From 8d13d028136dc84fd8e9f4ed65b06ce89c41fb11 Mon Sep 17 00:00:00 2001 From: Felix Angelov Date: Tue, 28 Mar 2023 17:31:21 -0500 Subject: [PATCH] refactor(updater): remove diff check (#191) --- updater/library/src/network.rs | 6 +----- updater/library/src/updater.rs | 17 +++++++---------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/updater/library/src/network.rs b/updater/library/src/network.rs index e1fb00eb..b4be605e 100644 --- a/updater/library/src/network.rs +++ b/updater/library/src/network.rs @@ -23,11 +23,7 @@ pub struct Patch { /// Legacy: originally "#" before we implemented hash checks (remove). pub hash: String, /// The URL to download the patch file from. - pub download_url: String, - /// Whether the artifact is a diff (modern) or full (legacy) artifact. - /// Will eventually be removed once we no longer support legacy artifacts. - #[serde(default)] - pub is_diff: bool, + pub download_url: String, } #[derive(Debug, Serialize)] diff --git a/updater/library/src/updater.rs b/updater/library/src/updater.rs index 1b09e7f3..95aef53a 100644 --- a/updater/library/src/updater.rs +++ b/updater/library/src/updater.rs @@ -142,17 +142,14 @@ fn update_internal(config: &ResolvedConfig) -> anyhow::Result { let patch = response.patch.ok_or(UpdateError::BadServerResponse)?; let download_dir = PathBuf::from(&config.cache_dir); - let mut download_path = download_dir.join(patch.number.to_string()); + let download_path = download_dir.join(patch.number.to_string()); download_to_path(&patch.download_url, &download_path)?; - // Inflate the patch from a diff if needed. - if patch.is_diff { - let base_path = PathBuf::from(&config.original_libapp_path); - let output_path = download_dir.join(format!("{}.full", patch.number.to_string())); - inflate(&download_path, &base_path, &output_path)?; - download_path = output_path; - } - + // Inflate the patch from a diff. + let base_path = PathBuf::from(&config.original_libapp_path); + let output_path = download_dir.join(format!("{}.full", patch.number.to_string())); + inflate(&download_path, &base_path, &output_path)?; + // Check the hash before moving into place. let hash_ok = check_hash(&download_path, &patch.hash)?; if !hash_ok { @@ -162,7 +159,7 @@ fn update_internal(config: &ResolvedConfig) -> anyhow::Result { // Consider supporting allowing the system to download for us (e.g. iOS). let patch_info = PatchInfo { - path: download_path.to_str().unwrap().to_string(), + path: output_path.to_str().unwrap().to_string(), number: patch.number, }; state.install_patch(patch_info)?;