diff --git a/Cargo.lock b/Cargo.lock index 3769213..98e5559 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -951,9 +951,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.6" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd" +checksum = "379dada1584ad501b383485dd706b8afb7a70fcbc7f4da7d780638a5a6124a60" [[package]] name = "hex" diff --git a/src/download.rs b/src/download.rs index 728be9c..8baa211 100644 --- a/src/download.rs +++ b/src/download.rs @@ -91,9 +91,11 @@ pub async fn clean( /// Construct a `to_install` vector from the `directory` pub fn read_overrides(directory: &Path) -> Result> { let mut to_install = Vec::new(); - for file in read_dir(directory)? { - let file = file?; - to_install.push((file.file_name(), file.path())); + if directory.exists() { + for file in read_dir(directory)? { + let file = file?; + to_install.push((file.file_name(), file.path())); + } } Ok(to_install) } @@ -104,7 +106,6 @@ pub async fn download( to_download: Vec, to_install: Vec<(OsString, PathBuf)>, ) -> Result<()> { - create_dir_all(&output_dir).await?; let progress_bar = Arc::new(Mutex::new( ProgressBar::new( to_download @@ -159,20 +160,20 @@ pub async fn download( .map_err(|_| anyhow!("Failed to run threads to completion"))? .into_inner()? .finish_and_clear(); - for installable in to_install { - if installable.1.is_file() { - copy(installable.1, output_dir.join(&installable.0)).await?; - } else if installable.1.is_dir() { + for (name, path) in to_install { + if path.is_file() { + copy(path, output_dir.join(&name)).await?; + } else if path.is_dir() { let mut copy_options = DirCopyOptions::new(); copy_options.overwrite = true; - copy_dir(installable.1, &*output_dir, ©_options)?; + copy_dir(path, &*output_dir, ©_options)?; } else { - bail!("Could not determine whether installable is file/folder") + bail!("Could not determine whether installable is a file or folder") } println!( "{} Installed {}", &*TICK, - installable.0.to_string_lossy().dimmed() + name.to_string_lossy().dimmed() ); } diff --git a/src/subcommands/modpack/delete.rs b/src/subcommands/modpack/delete.rs index d6f39aa..bc601c4 100644 --- a/src/subcommands/modpack/delete.rs +++ b/src/subcommands/modpack/delete.rs @@ -49,7 +49,7 @@ pub fn delete( return Ok(()); } }; - config.modpacks.swap_remove(selection); + config.modpacks.remove(selection); // If the currently selected modpack is being removed if config.active_modpack == selection { diff --git a/src/subcommands/profile/delete.rs b/src/subcommands/profile/delete.rs index d0a9c29..a9848fa 100644 --- a/src/subcommands/profile/delete.rs +++ b/src/subcommands/profile/delete.rs @@ -46,7 +46,7 @@ pub fn delete( return Ok(()); } }; - config.profiles.swap_remove(selection); + config.profiles.remove(selection); // If the currently selected profile is being removed if config.active_profile == selection {