fix(update): improve verified update cleanup and diagnostics
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
parent
8d32a0e01b
commit
ee78cc18fd
2 changed files with 30 additions and 6 deletions
|
|
@ -343,8 +343,17 @@ fn update_daemon_agent(
|
|||
bail!("run osascript failed: {}", e);
|
||||
}
|
||||
Ok(output) if !output.status.success() => {
|
||||
log::warn!("run osascript failed with status: {}", output.status);
|
||||
bail!("run osascript failed with status: {}", output.status);
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
log::warn!(
|
||||
"run osascript failed with status: {}, stderr: {}",
|
||||
output.status,
|
||||
stderr.trim()
|
||||
);
|
||||
bail!(
|
||||
"run osascript failed with status: {}, stderr: {}",
|
||||
output.status,
|
||||
stderr.trim()
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
let installed = std::path::Path::new(&agent_plist_file).exists();
|
||||
|
|
@ -1000,8 +1009,17 @@ fn update_me_from_app_dir(app_dir: String, keep_current_process: bool) -> Result
|
|||
.output();
|
||||
match output {
|
||||
Ok(output) if !output.status.success() => {
|
||||
log::error!("osascript execution failed with status: {}", output.status);
|
||||
bail!("osascript execution failed with status: {}", output.status);
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
log::error!(
|
||||
"osascript execution failed with status: {}, stderr: {}",
|
||||
output.status,
|
||||
stderr.trim()
|
||||
);
|
||||
bail!(
|
||||
"osascript execution failed with status: {}, stderr: {}",
|
||||
output.status,
|
||||
stderr.trim()
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("run osascript failed: {}", e);
|
||||
|
|
|
|||
|
|
@ -3765,10 +3765,12 @@ fn copy_update_file_for_verification(file: &str) -> ResultType<VerifiedUpdateFil
|
|||
}
|
||||
};
|
||||
if let Err(e) = std::io::copy(&mut source_file, &mut copy_file) {
|
||||
drop(copy_file);
|
||||
std::fs::remove_file(&path).ok();
|
||||
return Err(e.into());
|
||||
}
|
||||
if let Err(e) = copy_file.flush() {
|
||||
drop(copy_file);
|
||||
std::fs::remove_file(&path).ok();
|
||||
return Err(e.into());
|
||||
}
|
||||
|
|
@ -3798,14 +3800,18 @@ pub fn verify_update_file_signature_and_sha256(
|
|||
let update_path = match update_file.path_str() {
|
||||
Ok(path) => path.to_owned(),
|
||||
Err(e) => {
|
||||
std::fs::remove_file(&update_file.path).ok();
|
||||
let path = update_file.path.clone();
|
||||
drop(update_file);
|
||||
std::fs::remove_file(&path).ok();
|
||||
return Err(e);
|
||||
}
|
||||
};
|
||||
if let Err(e) = verify_update_file_sha256(&mut update_file.file, expected_sha256, &update_path)
|
||||
.and_then(|_| verify_update_file_signature_for_path(&update_path))
|
||||
{
|
||||
std::fs::remove_file(&update_file.path).ok();
|
||||
let path = update_file.path.clone();
|
||||
drop(update_file);
|
||||
std::fs::remove_file(&path).ok();
|
||||
return Err(e);
|
||||
}
|
||||
Ok(update_file)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue