mirror of
https://github.com/pesde-pkg/pesde.git
synced 2024-12-12 11:00:36 +00:00
refactor: only store pesde_version exes in version cache
This commit is contained in:
parent
5a82f8616f
commit
763bf2698f
3 changed files with 6 additions and 55 deletions
|
@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Fixed
|
||||
- Fix `self-install` doing a cross-device move by @daimond113
|
||||
|
||||
### Changed
|
||||
- Only store `pesde_version` executables in the version cache by @daimond113
|
||||
|
||||
## [0.5.0-rc.9] - 2024-11-16
|
||||
### Fixed
|
||||
- Correctly link Wally server packages by @daimond113
|
||||
|
|
|
@ -243,42 +243,6 @@ pub async fn get_or_download_version(
|
|||
})
|
||||
}
|
||||
|
||||
pub async fn max_installed_version() -> anyhow::Result<Version> {
|
||||
let versions_dir = home_dir()?.join("versions");
|
||||
fs::create_dir_all(&versions_dir)
|
||||
.await
|
||||
.context("failed to create versions directory")?;
|
||||
|
||||
let mut read_dir = fs::read_dir(versions_dir)
|
||||
.await
|
||||
.context("failed to read versions directory")?;
|
||||
let mut max_version = current_version();
|
||||
|
||||
while let Some(entry) = read_dir.next_entry().await? {
|
||||
#[cfg(not(windows))]
|
||||
let name = entry
|
||||
.path()
|
||||
.file_name()
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
#[cfg(windows)]
|
||||
let name = entry
|
||||
.path()
|
||||
.file_stem()
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
|
||||
let version = Version::parse(&name).unwrap();
|
||||
if version > max_version {
|
||||
max_version = version;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(max_version)
|
||||
}
|
||||
|
||||
pub async fn update_bin_exe(downloaded_file: &Path) -> anyhow::Result<()> {
|
||||
let bin_exe_path = bin_dir().await?.join(format!(
|
||||
"{}{}",
|
||||
|
|
22
src/main.rs
22
src/main.rs
|
@ -1,7 +1,5 @@
|
|||
#[cfg(feature = "version-management")]
|
||||
use crate::cli::version::{
|
||||
check_for_updates, current_version, get_or_download_version, max_installed_version,
|
||||
};
|
||||
use crate::cli::version::{check_for_updates, get_or_download_version};
|
||||
use crate::cli::{auth::get_tokens, display_err, home_dir, HOME_DIR};
|
||||
use anyhow::Context;
|
||||
use clap::Parser;
|
||||
|
@ -248,19 +246,11 @@ async fn run() -> anyhow::Result<()> {
|
|||
.ok()
|
||||
.and_then(|manifest| manifest.pesde_version);
|
||||
|
||||
// store the current version in case it needs to be used later
|
||||
get_or_download_version(&reqwest, ¤t_version(), false).await?;
|
||||
|
||||
let exe_path = if let Some(version) = target_version {
|
||||
Some(get_or_download_version(&reqwest, &version, false).await?)
|
||||
get_or_download_version(&reqwest, &version, false).await?
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let exe_path = if let Some(exe_path) = exe_path {
|
||||
exe_path
|
||||
} else {
|
||||
get_or_download_version(&reqwest, &max_installed_version().await?, false).await?
|
||||
};
|
||||
|
||||
if let Some(exe_path) = exe_path {
|
||||
let status = std::process::Command::new(exe_path)
|
||||
|
@ -277,13 +267,7 @@ async fn run() -> anyhow::Result<()> {
|
|||
);
|
||||
}
|
||||
|
||||
let cli = match Cli::try_parse() {
|
||||
Ok(cli) => cli,
|
||||
Err(err) => {
|
||||
let _ = err.print();
|
||||
std::process::exit(err.exit_code());
|
||||
}
|
||||
};
|
||||
let cli = Cli::parse();
|
||||
|
||||
cli.subcommand.run(project, multi, reqwest).await
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue