Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added gh_assets/auto-update-setting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gh_assets/modrinth-search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gh_assets/modrinth-sync.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gh_assets/modrinth-updates.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
153 changes: 80 additions & 73 deletions src-tauri/Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ chrono = { version = "0.4", features = ["serde"] }
rand = "0.9"
md5 = "0.7.0"
sha1 = "0.10"
sha2 = "0.10"
base16ct = {version = "0.2.0", features = ["alloc"] }

# UI library
Expand All @@ -69,6 +70,7 @@ azalea-auth = { git = "https://github.com/CCBlueX/azalea.git", branch = "custom_
# Data serialization libs
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
urlencoding = "2.1"

[features]
# by default Tauri runs in production mode
Expand Down
55 changes: 54 additions & 1 deletion src-tauri/src/app/gui/commands/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

use anyhow::anyhow;
use backon::{ExponentialBuilder, Retryable};
use std::collections::HashMap;
use std::path::PathBuf;
use std::{
sync::{Arc, Mutex},
Expand All @@ -28,6 +29,7 @@ use tauri::{Emitter, Window};
use tokio::fs;
use tracing::{error, info, warn};
use uuid::Uuid;
use serde_json;

use crate::app::client_api::{BlogPost, Branches, Build, Changelog, Client, PaginatedResponse};
use crate::app::client_api::{LoaderMod, ModSource};
Expand Down Expand Up @@ -195,11 +197,62 @@ pub(crate) async fn delete_custom_mod(
let mod_path = mod_cache_path.join(mod_name);

if mod_path.exists() {
fs::remove_file(mod_path)
fs::remove_file(&mod_path)
.await
.map_err(|e| format!("unable to delete custom mod: {:?}", e))?;
}

// Remove Modrinth metadata entry for this mod
let metadata_path = mod_cache_path.join(".modrinth_meta.json");
if metadata_path.exists() {
match fs::read_to_string(&metadata_path).await {
Ok(content) => {
match serde_json::from_str::<HashMap<String, serde_json::Value>>(&content) {
Ok(mut metadata) => {
let filename_without_ext = mod_name.replace(".jar", "");
let mut found = false;
metadata.retain(|_key, value| {
if let Some(file) = value.get("filename").and_then(|f| f.as_str()) {
if file == mod_name || file.replace(".jar", "") == filename_without_ext {
found = true;
return false;
}
}
true
});

if found {
if metadata.is_empty() {
// Remove metadata file if empty
if let Err(e) = fs::remove_file(&metadata_path).await {
warn!("Failed to remove empty Modrinth metadata file: {:?}", e);
}
} else {
// Save updated metadata
match serde_json::to_string(&metadata) {
Ok(json) => {
if let Err(e) = fs::write(&metadata_path, json).await {
warn!("Failed to update Modrinth metadata file: {:?}", e);
}
}
Err(e) => {
warn!("Failed to serialize Modrinth metadata: {:?}", e);
}
}
}
}
}
Err(e) => {
warn!("Failed to parse Modrinth metadata file: {:?}", e);
}
}
}
Err(e) => {
warn!("Failed to read Modrinth metadata file: {:?}", e);
}
}
}

Ok(())
}

Expand Down
2 changes: 2 additions & 0 deletions src-tauri/src/app/gui/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ pub(crate) mod auth;
pub(crate) mod client;
pub(crate) mod data;
pub(crate) mod system;
pub(crate) mod modrinth;

pub(crate) use auth::*;
pub(crate) use client::*;
pub(crate) use data::*;
pub(crate) use system::*;
pub(crate) use modrinth::*;
Loading