You've already forked AstralRinth
forked from didirus/AstralRinth
Bug fixes round 3 (#298)
* fixed bugs * title case * bugs; ioerror * reset breadcrumbs * more fixes * more fixes * scrolling bug * more fixes * more fixes * clippy * canonicalize fix * fixed requested changes * removed debouncer update
This commit is contained in:
@@ -9,6 +9,7 @@ use crate::pack::install_from::{
|
||||
use crate::prelude::JavaVersion;
|
||||
use crate::state::ProjectMetadata;
|
||||
|
||||
use crate::util::io::{self, IOError};
|
||||
use crate::{
|
||||
auth::{self, refresh},
|
||||
event::{emit::emit_profile, ProfilePayloadType},
|
||||
@@ -27,11 +28,7 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
use tokio::io::AsyncReadExt;
|
||||
use tokio::{
|
||||
fs::{self, File},
|
||||
process::Command,
|
||||
sync::RwLock,
|
||||
};
|
||||
use tokio::{fs::File, process::Command, sync::RwLock};
|
||||
|
||||
/// Remove a profile
|
||||
#[tracing::instrument]
|
||||
@@ -110,8 +107,8 @@ pub async fn edit_icon(
|
||||
) -> crate::Result<()> {
|
||||
let state = State::get().await?;
|
||||
|
||||
if let Some(icon) = icon_path {
|
||||
let bytes = tokio::fs::read(icon).await?;
|
||||
let res = if let Some(icon) = icon_path {
|
||||
let bytes = io::read(icon).await?;
|
||||
|
||||
let mut profiles = state.profiles.write().await;
|
||||
|
||||
@@ -133,8 +130,6 @@ pub async fn edit_icon(
|
||||
ProfilePayloadType::Edited,
|
||||
)
|
||||
.await?;
|
||||
State::sync().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
None => Err(crate::ErrorKind::UnmanagedProfileError(
|
||||
@@ -151,7 +146,9 @@ pub async fn edit_icon(
|
||||
State::sync().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
};
|
||||
State::sync().await?;
|
||||
res
|
||||
}
|
||||
|
||||
// Gets the optimal JRE key for the given profile, using Daedalus
|
||||
@@ -416,7 +413,7 @@ pub async fn add_project_from_path(
|
||||
project_type: Option<String>,
|
||||
) -> crate::Result<PathBuf> {
|
||||
if let Some(profile) = get(profile_path, None).await? {
|
||||
let file = fs::read(path).await?;
|
||||
let file = io::read(path).await?;
|
||||
let file_name = path
|
||||
.file_name()
|
||||
.unwrap_or_default()
|
||||
@@ -525,7 +522,9 @@ pub async fn export_mrpack(
|
||||
|
||||
let profile_base_path = &profile.path;
|
||||
|
||||
let mut file = File::create(export_path).await?;
|
||||
let mut file = File::create(&export_path)
|
||||
.await
|
||||
.map_err(|e| IOError::with_path(e, &export_path))?;
|
||||
let mut writer = ZipFileWriter::new(&mut file);
|
||||
|
||||
// Create mrpack json configuration file
|
||||
@@ -592,9 +591,13 @@ pub async fn export_mrpack(
|
||||
|
||||
// File is not in the config file, add it to the .mrpack zip
|
||||
if path.is_file() {
|
||||
let mut file = File::open(&path).await?;
|
||||
let mut file = File::open(&path)
|
||||
.await
|
||||
.map_err(|e| IOError::with_path(e, &path))?;
|
||||
let mut data = Vec::new();
|
||||
file.read_to_end(&mut data).await?;
|
||||
file.read_to_end(&mut data)
|
||||
.await
|
||||
.map_err(|e| IOError::with_path(e, &path))?;
|
||||
let builder = ZipEntryBuilder::new(
|
||||
format!("overrides/{relative_path}"),
|
||||
Compression::Deflate,
|
||||
@@ -639,13 +642,21 @@ pub async fn get_potential_override_folders(
|
||||
let mrpack_files = get_modrinth_pack_list(&mrpack);
|
||||
|
||||
let mut path_list: Vec<PathBuf> = Vec::new();
|
||||
let mut read_dir = fs::read_dir(&profile_path).await?;
|
||||
while let Some(entry) = read_dir.next_entry().await? {
|
||||
let mut read_dir = io::read_dir(&profile_path).await?;
|
||||
while let Some(entry) = read_dir
|
||||
.next_entry()
|
||||
.await
|
||||
.map_err(|e| IOError::with_path(e, &profile_path))?
|
||||
{
|
||||
let path: PathBuf = entry.path();
|
||||
if path.is_dir() {
|
||||
// Two layers of files/folders if its a folder
|
||||
let mut read_dir = fs::read_dir(&path).await?;
|
||||
while let Some(entry) = read_dir.next_entry().await? {
|
||||
let mut read_dir = io::read_dir(&path).await?;
|
||||
while let Some(entry) = read_dir
|
||||
.next_entry()
|
||||
.await
|
||||
.map_err(|e| IOError::with_path(e, &profile_path))?
|
||||
{
|
||||
let path: PathBuf = entry.path();
|
||||
let name = path.strip_prefix(&profile_path)?.to_path_buf();
|
||||
if !mrpack_files.contains(&name.to_string_lossy().to_string()) {
|
||||
@@ -712,9 +723,11 @@ pub async fn run_credentials(
|
||||
let result = Command::new(command)
|
||||
.args(&cmd.collect::<Vec<&str>>())
|
||||
.current_dir(path)
|
||||
.spawn()?
|
||||
.spawn()
|
||||
.map_err(|e| IOError::with_path(e, path))?
|
||||
.wait()
|
||||
.await?;
|
||||
.await
|
||||
.map_err(IOError::from)?;
|
||||
|
||||
if !result.success() {
|
||||
return Err(crate::ErrorKind::LauncherError(format!(
|
||||
@@ -925,8 +938,12 @@ pub async fn build_folder(
|
||||
path: &Path,
|
||||
path_list: &mut Vec<PathBuf>,
|
||||
) -> crate::Result<()> {
|
||||
let mut read_dir = fs::read_dir(path).await?;
|
||||
while let Some(entry) = read_dir.next_entry().await? {
|
||||
let mut read_dir = io::read_dir(path).await?;
|
||||
while let Some(entry) = read_dir
|
||||
.next_entry()
|
||||
.await
|
||||
.map_err(|e| IOError::with_path(e, path))?
|
||||
{
|
||||
let path = entry.path();
|
||||
if path.is_dir() {
|
||||
build_folder(&path, path_list).await?;
|
||||
|
||||
Reference in New Issue
Block a user