refactor(updater): remove diff check (#191)

This commit is contained in:
Felix Angelov
2023-03-28 17:31:21 -05:00
committed by GitHub
parent 0cac02866d
commit 8d13d02813
2 changed files with 8 additions and 15 deletions
+1 -5
View File
@@ -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)]
+7 -10
View File
@@ -142,17 +142,14 @@ fn update_internal(config: &ResolvedConfig) -> anyhow::Result<UpdateStatus> {
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<UpdateStatus> {
// 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)?;