Log update errors (#1362)

* Remove unused functions, log update errors

* Remove some outdated comments
This commit is contained in:
Dániel Buga 2022-09-27 21:23:28 +02:00 committed by GitHub
parent e095b0a70d
commit f4a93b61f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 63 deletions

View File

@ -158,49 +158,3 @@ pub fn restart(path: &Path) -> Result<()> {
.spawn()?;
Ok(())
}
#[cfg(target_os = "macos")]
pub fn update(_process_id: &str, src: &Path, dest: &Path) -> Result<()> {
let info = dmg::Attach::new(src).with()?;
if dest.file_name().and_then(|s| s.to_str()) == Some("MacOS") {
dest.parent().unwrap().parent().unwrap().parent().unwrap()
} else {
dest
};
let _ = std::fs::remove_dir_all(dest.join("Lapce.app"));
fs_extra::copy_items(
&[info.mount_point.join("Lapce.app")],
dest,
&fs_extra::dir::CopyOptions {
overwrite: true,
skip_exist: false,
buffer_size: 64000,
copy_inside: true,
content_only: false,
depth: 0,
},
)?;
std::process::Command::new("open")
.arg(dest.join("Lapce.app"))
.output()?;
Ok(())
}
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
pub fn update(_process_id: &str, src: &Path, dest: &Path) -> Result<()> {
let tar_gz = std::fs::File::open(src)?;
let tar = flate2::read::GzDecoder::new(tar_gz);
let mut archive = tar::Archive::new(tar);
let parent = src.parent().ok_or_else(|| anyhow::anyhow!("no parent"))?;
archive.unpack(parent)?;
let dest = dest.join("lapce");
std::fs::copy(parent.join("Lapce").join("lapce"), &dest)?;
let _ = std::process::Command::new(dest).arg("&").output();
Ok(())
}
#[cfg(target_os = "windows")]
pub fn update(_process_id: &str, _src: &Path, _dest: &Path) -> Result<()> {
Ok(())
}

View File

@ -302,13 +302,6 @@ fn layout(
Point::new(self.padding, self.padding * 2.0 + self.svg_size),
));
// GitHub: {}\nDiscord: {}\nMatrix: {}\n\n\nThird party resources used:\n\nCodicons (CC-BY-4.0)\n{}
// "https://lapce.dev",
// "https://github.com/lapce/lapce",
// "https://discord.gg/n8tGJ6Rn6D",
// "https://matrix.to/#/#lapce-editor:matrix.org",
// "https://github.com/microsoft/vscode-codicons"
let mut y = self.padding * 2.0
+ self.svg_size
+ title_size.height

View File

@ -375,16 +375,27 @@ fn command(
let _ = data.db.save_app(data);
let process_path = process_path.clone();
let release = release.clone();
std::thread::spawn(move || -> anyhow::Result<()> {
log::info!("start to down new versoin");
let src =
lapce_data::update::download_release(&release)?;
log::info!("start to extract");
let path =
lapce_data::update::extract(&src, &process_path)?;
log::info!("now restart {path:?}");
lapce_data::update::restart(&path)?;
Ok(())
std::thread::spawn(move || {
let do_update = || -> anyhow::Result<()> {
log::info!("start to down new versoin");
let src =
lapce_data::update::download_release(&release)?;
log::info!("start to extract");
let path = lapce_data::update::extract(
&src,
&process_path,
)?;
log::info!("now restart {path:?}");
lapce_data::update::restart(&path)?;
Ok(())
};
if let Err(err) = do_update() {
log::error!("Failed to update: {err}");
}
});
return druid::Handled::Yes;
}