From efd19f4399147ec16334714d9b75b0ac307c31a5 Mon Sep 17 00:00:00 2001 From: Hamster5295 Date: Sat, 6 Jan 2024 18:11:00 +0800 Subject: [PATCH 1/2] Fix bug with file paths --- src/remote.rs | 7 +++++-- src/utils.rs | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/remote.rs b/src/remote.rs index 76481fd..0ae8eaa 100644 --- a/src/remote.rs +++ b/src/remote.rs @@ -296,7 +296,11 @@ pub async fn download(client: &Client, file_name: String, url: String) -> String }); utils::create_install_path(); - let path = format!("{}/{}.zip", utils::INSTALL_PATH, file_name); + let path = utils::get_install_path() + .join(file_name + ".zip") + .to_str() + .unwrap() + .to_string(); let mut writer = io::BufWriter::new( fs::OpenOptions::new() .create(true) @@ -337,7 +341,6 @@ pub async fn download(client: &Client, file_name: String, url: String) -> String } writer.flush().unwrap(); - path } diff --git a/src/utils.rs b/src/utils.rs index 6ae7f91..5a18f17 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,5 +1,9 @@ use console::style; -use std::{cmp::Ordering, fs, path::Path}; +use std::{ + cmp::Ordering, + fs, + path::{Path, PathBuf}, +}; use crate::version::{self, Version}; @@ -15,8 +19,14 @@ macro_rules! err { }; } +pub fn get_install_path() -> PathBuf { + std::env::current_exe() + .unwrap() + .with_file_name(INSTALL_PATH) +} + pub fn create_install_path() { - fs::create_dir_all(INSTALL_PATH) + fs::create_dir_all(get_install_path()) .unwrap_or_else(|err| err!("Unable to create install directory: ", err.to_string())); } @@ -24,7 +34,7 @@ pub fn get_installed_dirs() -> Vec { create_install_path(); let mut installs = vec![]; - for dir_result in fs::read_dir(INSTALL_PATH).unwrap() { + for dir_result in fs::read_dir(get_install_path()).unwrap() { let dir = dir_result.unwrap(); let path = dir.path(); if path.is_dir() { @@ -47,7 +57,7 @@ pub fn get_installed_versions() -> Vec { pub fn get_executables(dir: String) -> Vec { let mut files = vec![]; - for dir_result in fs::read_dir(Path::new(INSTALL_PATH).join(dir)).unwrap() { + for dir_result in fs::read_dir(get_install_path().join(dir)).unwrap() { let dir = dir_result.unwrap(); let path = dir.path(); if path.is_file() { @@ -144,6 +154,6 @@ where } pub fn uninstall_version(version: Version) { - fs::remove_dir_all(Path::new(INSTALL_PATH).join(version.dir_name())) + fs::remove_dir_all(get_install_path().join(version.dir_name())) .unwrap_or_else(|err| err!("Error when uninstalling:", err.to_string())); } From 44458ad88eeeb4c350021e9454537419e958e84d Mon Sep 17 00:00:00 2001 From: Hamster5295 Date: Sat, 6 Jan 2024 18:11:50 +0800 Subject: [PATCH 2/2] v0.1.1 --- CHANGELOG.md | 6 +++++- Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79d0679..db43d71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,4 +9,8 @@ This is the changelog of **Godo**, a version manager for [Godot Engine](https:// * `available` - Show the list of the available Godot Engine versions. * `list` - List the installed Godot Engines. * `run` - Run Godot Engine with specific version. -* Automatic installing, uninstalling and running features. \ No newline at end of file +* Automatic installing, uninstalling and running features. + +## [1.0.1] - 2024-1-6 +### Fixed +* Fixed the error file path when installing \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 2f681ba..7b64b5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -480,7 +480,7 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "godo" -version = "0.1.0" +version = "0.1.1" dependencies = [ "clap", "console", diff --git a/Cargo.toml b/Cargo.toml index a23c161..8129152 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "godo" -version = "0.1.0" +version = "0.1.1" authors = ["Hamster5295 "] edition = "2021" description = "A Version Manager for Godot Engine."