mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Propagate apply errors better
This commit is contained in:
@@ -39,19 +39,18 @@ pub fn apply<'a>(
|
||||
return Ok(applied_locator);
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Error applying package: {}", e);
|
||||
if restart {
|
||||
shared::start_package(&locator, exe_args, Some(constants::HOOK_ENV_RESTART))?;
|
||||
}
|
||||
bail!("Error applying package: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
None => {
|
||||
error!("Failed to locate full package to apply. Please provide with the --package {{path}} argument");
|
||||
if restart {
|
||||
shared::start_package(&locator, exe_args, Some(constants::HOOK_ENV_RESTART))?;
|
||||
}
|
||||
bail!("Failed to locate full package to apply. Please provide with the --package {{path}} argument");
|
||||
}
|
||||
}
|
||||
|
||||
// an error occurred if we're here, but we still want to restart the old version of the app if it was requested
|
||||
if restart {
|
||||
shared::start_package(&locator, exe_args, Some(constants::HOOK_ENV_RESTART))?;
|
||||
}
|
||||
|
||||
bail!("Apply failed, see logs for details.");
|
||||
}
|
||||
|
||||
@@ -6,10 +6,7 @@ use crate::{
|
||||
};
|
||||
use anyhow::{bail, Context, Result};
|
||||
use std::sync::mpsc;
|
||||
use std::{
|
||||
fs,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
use std::{fs, path::PathBuf};
|
||||
use velopack::{bundle::load_bundle_from_file, constants, locator::VelopackLocator};
|
||||
|
||||
// fn ropycopy<P1: AsRef<Path>, P2: AsRef<Path>>(source: &P1, dest: &P2) -> Result<()> {
|
||||
@@ -94,7 +91,7 @@ pub fn apply_package_impl(old_locator: &VelopackLocator, package: &PathBuf, run_
|
||||
// fourth, we make as backup of the current dir to temp_path_old
|
||||
info!("Backing up current dir to {}", &temp_path_old.to_string_lossy());
|
||||
shared::retry_io_ex(|| fs::rename(¤t_dir, &temp_path_old), 1000, 10)
|
||||
.context("Unable to start the update, because one or more running processes prevented it.")?;
|
||||
.context("Unable to start the update, because one or more running processes prevented it. Try again later, or if the issue persists, restart your computer.")?;
|
||||
|
||||
// let mut requires_robocopy = false;
|
||||
// if let Err(e) = fs::rename(¤t_dir, &temp_path_old) {
|
||||
@@ -107,7 +104,7 @@ pub fn apply_package_impl(old_locator: &VelopackLocator, package: &PathBuf, run_
|
||||
// if this fails we will yolo a rollback...
|
||||
info!("Replacing current dir with {}", &temp_path_new.to_string_lossy());
|
||||
shared::retry_io_ex(|| fs::rename(&temp_path_new, ¤t_dir), 1000, 30)
|
||||
.context("Unable to complete the update, and the app was left in a broken state. You may need to re-install")?;
|
||||
.context("Unable to complete the update, and the app was left in a broken state. You may need to re-install or repair this application manually.")?;
|
||||
|
||||
// if !requires_robocopy {
|
||||
// // if we didn't need robocopy for the backup, we don't need it for the deploy hopefully
|
||||
|
||||
@@ -4,10 +4,10 @@ pub mod shared;
|
||||
#[cfg(target_os = "windows")]
|
||||
pub mod windows;
|
||||
|
||||
pub use shared::{dialogs};
|
||||
pub use shared::dialogs;
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate simplelog;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
extern crate lazy_static;
|
||||
|
||||
Reference in New Issue
Block a user