Skip to content

Commit

Permalink
Merge pull request #188 from J-ZhengLi/dev-zhengli
Browse files Browse the repository at this point in the history
0.4.0 release
  • Loading branch information
J-ZhengLi authored Dec 26, 2024
2 parents 2cb0d88 + d3a2915 commit 45ea973
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rim"
version = "0.3.1"
version = "0.4.0"
edition = "2021"
description = "An interactive Rust installation manager"
rust-version = "1.73.0" # Minimal required version to use `zip`
Expand Down
2 changes: 1 addition & 1 deletion rim_dev/src/mocked/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fn gen_release_toml(version: &str) -> Result<()> {
/// The target version will always be one major release ahead of the current version,
/// so if the current version is `1.0.0`, the target version will be `2.0.0`.
fn mocked_ws_version() -> String {
let ws_manifest_content = include_str!("../../Cargo.toml");
let ws_manifest_content = include_str!("../../../Cargo.toml");
let cur_ver = ws_manifest_content
.lines()
.find_map(|line| {
Expand Down
2 changes: 1 addition & 1 deletion rim_gui/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rim-gui"
version = "0.3.1"
version = "0.4.0"
description = "An interactive Rust installation manager"
authors = ["you"]
edition = "2021"
Expand Down
19 changes: 8 additions & 11 deletions src/core/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ impl<'a> InstallConfiguration<'a> {
pub fn new(install_dir: &'a Path, manifest: &'a ToolsetManifest) -> Result<Self> {
Ok(Self {
install_dir: install_dir.to_path_buf(),
// Note: `InstallationRecord::load` creates `install_dir` if it does not exist
install_record: InstallationRecord::load(install_dir)?,
cargo_registry: None,
rustup_dist_server: default_rustup_dist_server().clone(),
Expand All @@ -103,15 +104,12 @@ impl<'a> InstallConfiguration<'a> {
/// Creating install diretory and other preperations related to filesystem.
///
/// This is suitable for first-time installation.
pub fn setup(&self) -> Result<()> {
pub fn setup(&mut self) -> Result<()> {
let install_dir = &self.install_dir;
let manifest = self.manifest;

info!("{}", t!("install_init", dir = install_dir.display()));

// Create a new folder to hold installation
utils::ensure_dir(install_dir)?;

// Create a copy of the manifest which is later used for component management.
let manifest_out_path = install_dir.join(ToolsetManifest::FILENAME);
utils::write_file(manifest_out_path, &manifest.to_toml()?, false)?;
Expand Down Expand Up @@ -381,8 +379,7 @@ impl<'a> InstallConfiguration<'a> {
/// otherwise this will copy that file into dest.
fn extract_or_copy_to(&self, maybe_file: &Path, dest: &Path) -> Result<PathBuf> {
if let Ok(mut extractable) = Extractable::load(maybe_file) {
extractable.extract_then_skip_solo_dir(dest, Some("bin"))?;
Ok(dest.to_path_buf())
extractable.extract_then_skip_solo_dir(dest, Some("bin"))
} else {
utils::copy_into(maybe_file, dest)
}
Expand Down Expand Up @@ -413,13 +410,13 @@ impl InstallConfiguration<'_> {
.insecure(self.insecure)
.update(self, manifest)?;

let record = &mut self.install_record;
// Add the rust info to the fingerprint.
self.install_record.update_rust(manifest.rust_version());
record.update_rust(manifest.rust_version());
// record meta info
self.install_record
.clone_toolkit_meta_from_manifest(manifest);
record.clone_toolkit_meta_from_manifest(manifest);
// write changes
self.install_record.write()?;
record.write()?;

self.inc_progress(60.0)
}
Expand Down Expand Up @@ -495,7 +492,7 @@ mod tests {

let install_root = tempfile::Builder::new().tempdir_in(&cache_dir).unwrap();
let manifest = get_toolset_manifest(None, false).unwrap();
let config = InstallConfiguration::new(install_root.path(), &manifest).unwrap();
let mut config = InstallConfiguration::new(install_root.path(), &manifest).unwrap();
config.setup().unwrap();

assert!(config.install_record.name.is_none());
Expand Down
5 changes: 1 addition & 4 deletions src/core/parser/fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ impl TomlParser for InstallationRecord {
where
Self: Sized + serde::de::DeserializeOwned,
{
assert!(
root.as_ref().is_dir(),
"install record needs to be loaded from a directory"
);
utils::ensure_dir(root.as_ref())?;

let fp_path = root.as_ref().join(Self::FILENAME);
if fp_path.is_file() {
Expand Down
2 changes: 1 addition & 1 deletion src/core/rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl ToolchainInstaller {
let rustup = ensure_rustup(config, manifest, self.insecure)?;
let tc_ver = manifest.rust_version();

utils::run!(&rustup, "toolchain", "add", tc_ver)
utils::run!(&rustup, "toolchain", "add", tc_ver, "--no-self-update")
}

// Rustup self uninstall all the components and toolchains.
Expand Down
8 changes: 7 additions & 1 deletion src/utils/extraction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,13 @@ impl<'a> Extractable<'a> {
stop: Option<S>,
) -> Result<PathBuf> {
fn inner_<S: AsRef<OsStr>>(root: &Path, stop: Option<S>) -> Result<PathBuf> {
if let [sub_dir] = super::walk_dir(root, false)?.as_slice() {
let sub_entries = if root.is_dir() {
super::walk_dir(root, false)?
} else {
return Ok(root.to_path_buf());
};

if let [sub_dir] = sub_entries.as_slice() {
if matches!(stop, Some(ref keyword) if filename_matches_keyword(sub_dir, keyword)) {
Ok(root.to_path_buf())
} else {
Expand Down

0 comments on commit 45ea973

Please sign in to comment.