refactor(updater): remove diff check (#191)
This commit is contained in:
@@ -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
@@ -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)?;
|
||||
|
||||
Reference in New Issue
Block a user