fix(self-update): fix windows self-update reporting failure on successful self-update (#1452)
This commit is contained in:
@@ -1062,14 +1062,6 @@ _version: 2
|
|||||||
zh_CN: "模拟运行"
|
zh_CN: "模拟运行"
|
||||||
zh_TW: "模擬執行"
|
zh_TW: "模擬執行"
|
||||||
de: "Testlauf"
|
de: "Testlauf"
|
||||||
"Topgrade Upgraded":
|
|
||||||
en: "Topgrade Upgraded"
|
|
||||||
lt: "Topgrade atnaujintas"
|
|
||||||
es: "Topgrade Actualizado"
|
|
||||||
fr: "Topgrade mis à jour"
|
|
||||||
zh_CN: "已升级 Topgrade"
|
|
||||||
zh_TW: "已更新 Topgrade"
|
|
||||||
de: "Topgrade aktualisiert"
|
|
||||||
|
|
||||||
# Summary texts
|
# Summary texts
|
||||||
"OK":
|
"OK":
|
||||||
|
|||||||
11
src/error.rs
11
src/error.rs
@@ -116,14 +116,3 @@ impl Display for SkipStep {
|
|||||||
write!(f, "{}", self.0)
|
write!(f, "{}", self.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(windows, feature = "self-update"))]
|
|
||||||
#[derive(Error, Debug)]
|
|
||||||
pub struct Upgraded(pub ExitStatus);
|
|
||||||
|
|
||||||
#[cfg(all(windows, feature = "self-update"))]
|
|
||||||
impl Display for Upgraded {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
write!(f, "{}", t!("Topgrade Upgraded"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ use tracing::debug;
|
|||||||
|
|
||||||
use self::config::{CommandLineArgs, Config};
|
use self::config::{CommandLineArgs, Config};
|
||||||
use self::error::StepFailed;
|
use self::error::StepFailed;
|
||||||
#[cfg(all(windows, feature = "self-update"))]
|
|
||||||
use self::error::Upgraded;
|
|
||||||
use self::runner::StepResult;
|
use self::runner::StepResult;
|
||||||
#[allow(clippy::wildcard_imports)]
|
#[allow(clippy::wildcard_imports)]
|
||||||
use self::steps::{remote::*, *};
|
use self::steps::{remote::*, *};
|
||||||
@@ -335,13 +333,6 @@ fn main() {
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
#[cfg(all(windows, feature = "self-update"))]
|
|
||||||
{
|
|
||||||
if let Some(Upgraded(status)) = error.downcast_ref::<Upgraded>() {
|
|
||||||
exit(status.code().unwrap());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let skip_print = (error.downcast_ref::<StepFailed>().is_some())
|
let skip_print = (error.downcast_ref::<StepFailed>().is_some())
|
||||||
|| (error
|
|| (error
|
||||||
.downcast_ref::<io::Error>()
|
.downcast_ref::<io::Error>()
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
use std::env;
|
use std::env;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::os::unix::process::CommandExt as _;
|
use std::os::unix::process::CommandExt as _;
|
||||||
|
#[cfg(windows)]
|
||||||
|
use std::process::exit;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
use crate::step::Step;
|
use crate::step::Step;
|
||||||
use color_eyre::eyre::{bail, Result};
|
#[cfg(unix)]
|
||||||
|
use color_eyre::eyre::bail;
|
||||||
|
use color_eyre::eyre::Result;
|
||||||
use rust_i18n::t;
|
use rust_i18n::t;
|
||||||
use self_update_crate::backends::github::Update;
|
use self_update_crate::backends::github::Update;
|
||||||
use self_update_crate::update::UpdateStatus;
|
use self_update_crate::update::UpdateStatus;
|
||||||
|
|
||||||
use super::terminal::{print_info, print_separator};
|
use super::terminal::{print_info, print_separator};
|
||||||
#[cfg(windows)]
|
|
||||||
use crate::error::Upgraded;
|
|
||||||
|
|
||||||
use crate::execution_context::ExecutionContext;
|
use crate::execution_context::ExecutionContext;
|
||||||
|
|
||||||
pub fn self_update(ctx: &ExecutionContext) -> Result<()> {
|
pub fn self_update(ctx: &ExecutionContext) -> Result<()> {
|
||||||
@@ -63,7 +64,7 @@ pub fn self_update(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
{
|
{
|
||||||
#[allow(clippy::disallowed_methods)]
|
#[allow(clippy::disallowed_methods)]
|
||||||
let status = command.status()?;
|
let status = command.status()?;
|
||||||
bail!(Upgraded(status));
|
exit(status.code().expect("This cannot return None on Windows"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user