refactor: only store pesde_version exes in version cache

This commit is contained in:
daimond113 2024-11-16 18:39:57 +01:00
parent 5a82f8616f
commit 763bf2698f
No known key found for this signature in database
GPG key ID: 3A8ECE51328B513C
3 changed files with 6 additions and 55 deletions

View file

@ -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

View file

@ -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!(
"{}{}",

View file

@ -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, &current_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
}